Hi All! I am running a multithread program and threads may stuck. I need to be able to terminate those threads after some defined period of time. I can't use a detach because I don't want to leave this thread run forever and I can't use join because the thread never ends. Any ideas? Please help :)
Igor -----Original Message----- From: zentara [mailto:[EMAIL PROTECTED] Sent: Monday, October 13, 2003 8:19 PM To: [EMAIL PROTECTED] Subject: Re: FW: threads in perl On Mon, 13 Oct 2003 18:29:09 +0200, [EMAIL PROTECTED] (Igor Ryaboy) wrote: >Very Nice , >There is only one unsolved issue here: Your program may exit with other threads are >still running , beside this I liked it very much. The actual solution you supplied is >the > use of threads->self function. ############################################ Yeah I fixed this. >#cleanup leftover running threads >print "data exhausted, waiting for threads to finish\n"; >threads->list()->join; Replace the above with: #cleanup leftover running threads print "data exhausted, waiting for threads to finish\n"; while (1){ @running_threads = threads->list; if (scalar(@running_threads) < 1){print "\nFinished\n";exit}else{next} } ################################################# >Thanks you very much!!! Your welcome, it was a learning experience for me too. :-) >Igor >BTW where can I get some documentation about threads::Pool? Download the module from cpan. But I just checked out the latest version of Threads::Pool and it only works with perl5.8.0-RC3 or later. I installed 5.81 to test it, but 5.81 broke some other modules I'm playing with. So.....it's up to you. Our body's 20 milligrams of beta radioactive Potassium 40 emit about 340 million neutrinos per day, which go at lightspeed to the ends of the universe!..even thru the earth. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>