Things that zoom. Usually this is just notes to my self about problems and solutions I've encountered when programming in java. On really fine days the guest bloggers write something here.
2009-05-25
Multi-threaded tests
Upplagd av
Magnus Reftel
kl.
Monday, May 25, 2009
Here's a little trick I used once to do some tests on threaded code: Wrap the thread library, and have the wrapper run one thread at a time (cooperative threading style, except yield() is implicit in all thread library calls) in a deterministic fashion. That makes the test repeatable and can detect any deadlocks that depend on which thread is scheduled at which yield() if you just re-run the test for all permutations of the scheduling order. On the minus side, you will never find any bugs that depend on scheduling another thread in the middle of something else (a side effect of the determinism you get from the cooperative threading), but my guess is that it's worth it in most cases.
Subscribe to:
Post Comments (Atom)
0 kommentarer:
Post a Comment