public void testQueue() throws Exception
{
HashSet threads = new HashSet();
// A chhanel of communication between workers and the test method
LinkedQueue testChannel = new LinkedQueue();
for (int i=0; i< NUMBER_OF_PRODUCERS; i++)
{
threads.add(new SeveralClientsStressTest.Producer(i, testChannel));
}
for (int i=0; i< NUMBER_OF_CONSUMERS; i++)
{
threads.add(new SeveralClientsStressTest.Consumer(i, testChannel));
}
for (Iterator iter = threads.iterator(); iter.hasNext();)
{
Worker worker = (Worker)iter.next();
worker.start();
}
long timeToFinish = System.currentTimeMillis() + TEST_ALIVE_FOR;
int numberOfProducers = NUMBER_OF_PRODUCERS +1;
int numberOfConsumers = NUMBER_OF_CONSUMERS +1;
while (threads.size()>0)
{
SeveralClientsStressTest.InternalMessage msg = (SeveralClientsStressTest.InternalMessage)testChannel.poll(2000);
log.info("Produced:" + producedMessages.get() + " and Consumed:" + readMessages.get() + " messages");
if (msg!=null)
{