How can master() function monitor the threads that are running?
# some code here.... for (0 ..3)) { my $thr = threads->create ( sub { worker(); } )->detach(); } # Master Thread while (1) { master(); } sub master { while (1) { #check if workers are alive #enqueue work # .... } } sub worker { while (1) { #dequeue work # .... } }
I Tried the below but it is not working?
my @threads = threads->list();
In reply to Monitor list of threads running by mr_p
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |