Code example for AtomicLong

0
 */ 
@Test 
public class StorageModificationLockTest { 
  private final static int         THREAD_COUNT     = 100;
  private final static int         CYCLES_COUNT     = 20;
  private final AtomicLong         counter          = new AtomicLong();
  private final OModificationLock  modificationLock = new OModificationLock();
  private final ExecutorService    executorService  = Executors.newFixedThreadPool(THREAD_COUNT + 1);
  private final List<Future<Void>> futures          = new ArrayList<Future<Void>>(THREAD_COUNT);
  private final CountDownLatch     countDownLatch   = new CountDownLatch(1);
 
  @Test 
  public void testLock() throws Exception { 
    for (int i = 0; i < THREAD_COUNT; i++) {
      futures.add(executorService.submit(new Counter()));
    } 
 
    Future<Void> prohibiter = executorService.submit(new Prohibiter());
    countDownLatch.countDown();
    prohibiter.get();
Experience pair programming with AI  Get Codota for Java