If you develop code, you're gonna love this.
I have a multi-threaded Perl ICB client that I wrote. I've always had an occasional problem with a race condition between different threads trying to write simultaneously to the screen. I thought I had it solved at one point, but all hell broke loose after I built a new babylon5 with a six-core processor. I tried various approaches to solve it, including meticulous use of Thread::Semaphore.
Well, I think I've finally solved the problem this time, by using a simple shared scalar as a semaphore and using lock($sem) instead of using a Thread::Semaphore object and $sem->down()/$sem->up() calls. But, the ironic, yet inescapable conclusion from this...?
Thread::Semaphore isn't thread-safe.
Tags: