in reply to Perl threads: using yield() and Time::HiRes usleep() in Linux/*nix

If you do a yield you're telling the sceduler that another thread may do its business. Whether another thread will do so depends on whether there's another thread wanting the CPU, and on implementation details of your OSses sceduler. But you are doing the sleep only after the thread gets another timeslice. During the sleep, other threads (or processes) may do their thing.

I'm not a thread expert, but I think the best thing you can do is leave the sleep in, and remove the yield.

  • Comment on Re: Perl threads: using yield() and Time::HiRes usleep() in Linux/*nix
  • Download Code