@@ -45,17 +45,18 @@ public AddressBook getStub() throws Exception {
4545
4646 private void testMultithreading (StubSupplier stubSupplier ) throws Throwable {
4747 Report report = new Report ();
48- int NUM_THREADS = 50 ;
49- CountDownLatch readyLatch = new CountDownLatch (NUM_THREADS );
48+ final int numThreads = 50 ;
49+ final int numInvocations = 4 ;
50+ CountDownLatch readyLatch = new CountDownLatch (numThreads );
5051 CountDownLatch startLatch = new CountDownLatch (1 );
51- Thread [] threads = new Thread [NUM_THREADS ];
52- for (int i = 0 ; i < NUM_THREADS ; ++i ) {
53- threads [i ] = new Thread (new Invoker (stubSupplier .getStub (), readyLatch , startLatch , report ));
52+ Thread [] threads = new Thread [numThreads ];
53+ for (int i = 0 ; i < numThreads ; ++i ) {
54+ threads [i ] = new Thread (new Invoker (stubSupplier .getStub (), readyLatch , startLatch , report , numInvocations ));
5455 threads [i ].start ();
5556 }
5657 readyLatch .await ();
5758 startLatch .countDown ();
58- for (int i = 0 ; i < NUM_THREADS ; ++i ) {
59+ for (int i = 0 ; i < numThreads ; ++i ) {
5960 threads [i ].join (30000 );
6061 StackTraceElement [] stack = threads [i ].getStackTrace ();
6162 if (stack .length > 0 ) {
@@ -68,7 +69,7 @@ private void testMultithreading(StubSupplier stubSupplier) throws Throwable {
6869 if (error != null ) {
6970 throw error ;
7071 }
71- assertEquals ("number of successes" , NUM_THREADS * 4 , report .getSuccessCount ());
72+ assertEquals ("number of successes" , numThreads * numInvocations , report .getSuccessCount ());
7273 } // testMultithreading
7374} // class MultithreadTestCase
7475
0 commit comments