Hi Szabolcs,
On 4/22/07, Ferenczi, Szabolcs <
ferenczi@...> wrote:
> [...]
> I am going to demonstrate TDD for multi-threading applications on a
> case study for your convenience. Let us suppose that we are about to
> introduce the classical producer-consumer scenario and we must develop
> a bounded buffer to smooth the varying speed difference between
> producer and consumer threads.
> [...]
Thanks for posting the scenario. It's a lot of work to narrate
something like that into an email but there's a big audience out there
that doesn't have much written material to reference when test-driving
concurrent programs (that's also why I devoted a chapter of my book
for talking about test-driving unpredictable code).
Having said that, I have to note that using Thread#getState() is not
something you can absolutely rely on as the behavior isn't guaranteed
to be the same on all platforms. That is, it can be a useful tool for
debugging and test-driving but not ideal for regression (unit)
testing.
Lasse