ConnectionStatus { public void switchToUsing() { isUsing = true; }  void switchToUsing(); void switchToReleased(); void waitUntilConnectionRelease();  }
@Test public void assertSwitchToUsing() throws InterruptedException, IllegalAccessException { AtomicInteger counter = new AtomicInteger(); for (int i = 0; i < numberOfThreads; i++) { service.submit(() -> { connectionStatus.switchToUsing(); counter.incrementAndGet(); latch.countDown(); }); } latch.await(); assertThat(numberOfThreads, is(counter.get())); assertThat(usingField.getBoolean(connectionStatus), is(true)); }