Fun With Threads
I'm doing a project that is heavily multi-threaded now, so I got a chance to experiance the love :-)
A couple of pretty obvious things that you may want to remember:
- If your tests execute multi threaded code, make sure that the code has finished running before the test complete. I got a couple of interesting bugs this way, and I wasn't able to track them down until I realized that the test run, succeeded, and while the next test was being executed, stuff was happening that started in the previous test.
- It is probably not a good idea to do a thread.Join() on a ThreadPool thread :-)
By the way, anyone knows of a way to wait until all the specified work was done? For instance, I got 10 pieces of work, and I queue them in the ThreadPool. I want to wait until all 10 are done, with a timeout. The exact opposite Semaphore, actually. I remember something like this from Win32, where there was a thread synchronization primivite like that, but I can remember which, and I can't even be sure that I recall it correctly.
Right now I rolled my owned, which is a Bad Thing to do, I know.
Comments
Comment preview