Context ctx = createContext();
HashSet threads = new HashSet();
// A chhanel of communication between workers and the test method
LinkedBlockingQueue testChannel = new LinkedBlockingQueue();
for (int i = 0; i < SeveralClientsStressTest.NUMBER_OF_PRODUCERS; i++)
{
threads.add(new SeveralClientsStressTest.Producer(i, testChannel));
}
for (int i = 0; i < SeveralClientsStressTest.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() + SeveralClientsStressTest.TEST_ALIVE_FOR;
int numberOfProducers = SeveralClientsStressTest.NUMBER_OF_PRODUCERS;
int numberOfConsumers = SeveralClientsStressTest.NUMBER_OF_CONSUMERS;
while (threads.size() > 0)
{
SeveralClientsStressTest.InternalMessage msg = (SeveralClientsStressTest.InternalMessage)testChannel.poll(2000,
TimeUnit.MILLISECONDS);
log.info("Produced:" + SeveralClientsStressTest.producedMessages.get() +
" and Consumed:" +
SeveralClientsStressTest.readMessages.get() +