Following the logic of this test, I believe what you are doing is equivalent to:
- submit a series of tasks in a thread and use a latch to countdown each time a task is produced
- the tasks wait on another latch to countdown before completing
- each time a task runs, increase a counter
- in another thread, wait for the first latch to countdown, indicating that all tasks have been submitted, and check the running count to make sure blocking is occurring correctly
- decrease the second latch, all tasks should complete, verify that they do
- I believe doing this will avoid the while loops with sleeps in them waiting for transactions to complete
- have a second latch that counts down after this