in reply to Multithreading and Communication Among Perl Processes
#!/usr/bin/perl use threads; use threads::shared; use strict; our $a:shared = 1; print "main start->$a\n"; threads->create(\&display); threads->create(\&display1); print "hit enter to finish\n"; <STDIN>; #pauses for keypress print "main done-> $a\n"; sub display { our $a = 2; $a++; print "from t1->$a\n"; } sub display1 { our $a = 99; print "front2->$a\n"; $a++; lock $a; cond_broadcast($a); }
|
|---|