2 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use Thread::Semaphore;
my $todosem = new Thread::Semaphore;
my @TodoList;
...
my $temp = Thread->new(\&Monitor);
$todosem->down;
$TodoList[0][7] = "running";
$todosem->up;
foreach $thread (Thread->list) {
while(1){#wait for a thread to be finished
foreach $thread (Thread->list) {
$bool = $thread->done; #thread is done?
last if ($bool);# if $bool true exit foreach
}
last if ($bool);# if $bool true exit while
}
$thread->join();# join this Workerthread
}
sub Monitor(){
my $arraysize = @TodoList;
while (1) {
$todosem->down;
for(my $i=0; $i < $arraysize; $i++){
print $TodoList[$i][7];
}
$todosem->up;
sleep 5;
}
}
2 Einträge, 1 Seite |