|
Description
|
A DESCRIPTION OF THE REQUEST :
Testing concurrent code is hard. I find myself using a sleep() call in one thread so I can test what happens when another thread is first to enter await(). This delay has to be conservative, of course, given that other things contend for the CPU. This means that the test takes a whole lot longer than would be optimal.
Instead of sleep(), I'd like to use a CountDownLatch. So in the one thread, I do this
latch.await() // maybe with a timeout
and in the other thread, when the code enters barrier.await(), it invokes a listener that does this
latch.countDown()
I fear that this all boils down to wanting a notification when wait() has been entered on some objec, which of course would make this into a major request with far-reaching performance implications. I hope not. If so, then there could be a flag to the VM for a testing mode in which such things are possible.
JUSTIFICATION :
Speeding up test code.
Posted Date : 2005-11-15 22:40:28.0
|