views:

46

answers:

1

I am using perl ithreads and things work fine, unless I decide to have threads sleep.

Lets say my routine thread_job is passed as an entry for several threads to start running concurrently.

thread_job()
{
...
sleep 2;

#do other stuff here

}

If I dont have a sleep I have no issues with the threads running and they do their tasks fine. If I add a sleep, my script hangs. I am running this off a windows command prompt, if that helps.

Since I do need to sleep and Im guessing there's an issue with using this sleep on my current setup, I intend to have the thread do something, for a while, instead of sleeping. Is there any such mathematical operation which I could perform?

+1  A: 

Try using Win32::Sleep instead. (Note that it takes milliseconds as an argument, not seconds.)

Ether
Thanks I ll try this out!
decafa5c11
Hey thanks Win32::Sleep is much better!
decafa5c11
@decafa5c11: in that case please feel free to accept the answer (click on the outlined checkmark next to the answer). :)
Ether