[concurrency-interest] How has java.util.concurrent.locks been tested?

Oliver Zeigermann ozeigermann@apache.org
Thu, 30 Dec 2004 01:03:19 +0100


On Wed, 29 Dec 2004 18:51:19 -0500, Doug Lea <dl@cs.oswego.edu> wrote:
> >
> > http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/test/tck/
> >
> > I have found tests for the other classes, but not for the locks.
> 
> Well, there's ReentrantLockTest?

Ooops, sorry. Thanks for pointing at it. 

E.g. in testhasQueuedThreads I have found

Thread.sleep(SHORT_DELAY_MS);

which - I suppose - does what I was trying to do with my sequence
barrier. Especially when  you debug your code this is likely to fail,
isn't it?
 
> > Isn't it common practice to test multi-threaded scenarios?
> 
> Yes, we have a lot of them. Someday, they should be made presentable
> and posted. In general the key to good multithreaded tests is to find
> some way of detecting bad states (deadlock, bad field values, etc),
> and then run lots of threads on multiprocessors (to generate more
> interleavings), and with enough randomization to avoid getting stuck
> in unintersting patterns, and run for a while seeing if you hit any
> bad states.

Yes, of course, but once found shouldn't there be tests that
deterministically reproduce those bad states. At least for regression
testing?

If so this leads me back to my initial question: How to make
multi-threaded tests deterministic?

Oliver