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

Doug Lea dl@cs.oswego.edu
Wed, 29 Dec 2004 18:51:19 -0500

> 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?

> Additionally, I was a bit confused as in e.g. ConcurrentHashMapTest
> there are no multi-threaded tests as well.

TCK tests are pure conformance tests, so only use as many threads
as minimally needed (usually one) to check basic postconditions.

> 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.