Source:
public static void main(String[] arg) { try { if (arg.length != 4) { System.err.println("You need to pass in protocol, consumerType, Time, transaction"); System.exit(0); } String protocol = arg[0]; String consumerType = arg[1]; int time = Integer.parseInt(arg[2]); boolean tx = Boolean.parseBoolean(arg[3]); if (time == 0) { time = 15000; } final String host = "localhost"; final int port = 61616; final ConnectionFactory factory = createConnectionFactory(protocol, "tcp://" + host + ":" + port); CountDownLatch producersLatch = new CountDownLatch(producer_threads); CountDownLatch consumersLatch = new CountDownLatch(consumer_threads); for (int i = 0; i < producer_threads; i++) { Thread t = new Thread(new Runnable() { @Override public void run() { SoakPagingTest app = new SoakPagingTest(protocol, consumerType, tx); app.produce(factory, producer_count.incrementAndGet(), producersLatch); } }); t.start(); } Thread.sleep(1000); for (int i = 0; i < consumer_threads; i++) { Thread t = new Thread(new Runnable() { @Override public void run() { SoakPagingTest app = new SoakPagingTest(protocol, consumerType, tx); app.consume(factory, consumer_count.getAndIncrement(), consumersLatch); } }); t.start(); } System.out.println("Awaiting producers..."); if (!producersLatch.await(30000, TimeUnit.MILLISECONDS)) { System.out.println("Awaiting producers timeout"); } System.out.println("Awaiting consumers..."); if (!consumersLatch.await(30000, TimeUnit.MILLISECONDS)) { System.out.println("Awaiting consumers timeout"); } System.out.println("Awaiting timeout..."); Thread.sleep(time); int exitStatus = consumed.get() > 0 ? 1 : 0; System.out.println("Exiting with the status: " + exitStatus); System.exit(exitStatus); } catch (Throwable t) { System.err.println("Exiting with the status 0. Reason: " + t); t.printStackTrace(); System.exit(0); } }

Target:
public static void main(String[] arg) { try { if (arg.length != 4) { System.err.println("You need to pass in protocol, consumerType, Time, transaction"); System.exit(0); } String protocol = arg[0]; String consumerType = arg[1]; int time = Integer.parseInt(arg[2]); boolean tx = Boolean.parseBoolean(arg[3]); if (time == 0) { time = 15000; } final String host = "localhost"; final int port = 61616; final ConnectionFactory factory = createConnectionFactory(protocol, "tcp://" + host + ":" + port); CountDownLatch producersLatch = new CountDownLatch(producer_threads); CountDownLatch consumersLatch = new CountDownLatch(consumer_threads); for (int i = 0; i < producer_threads; i++) { Thread t = new Thread(new Runnable() { @Override public void run() { SoakPagingTest app = new SoakPagingTest(protocol, consumerType, tx); app.produce(factory, producer_count.incrementAndGet(), producersLatch); } }); t.start(); } Thread.sleep(1000); for (int i = 0; i < consumer_threads; i++) { Thread t = new Thread(new Runnable() { @Override public void run() { SoakPagingTest app = new SoakPagingTest(protocol, consumerType, tx); app.consume(factory, consumer_count.getAndIncrement(), consumersLatch); } }); t.start(); } System.out.println("Awaiting producers..."); if (!producersLatch.await(30000, TimeUnit.MILLISECONDS)) { System.err.println("Awaiting producers timeout"); System.exit(0); } System.out.println("Awaiting consumers..."); if (!consumersLatch.await(30000, TimeUnit.MILLISECONDS)) { System.err.println("Awaiting consumers timeout"); System.exit(0); } System.out.println("Awaiting timeout..."); Thread.sleep(time); int exitStatus = consumed.get() > 0 ? 1 : 0; System.out.println("Exiting with the status: " + exitStatus); System.exit(exitStatus); } catch (Throwable t) { System.err.println("Exiting with the status 0. Reason: " + t); t.printStackTrace(); System.exit(0); } }