Tabnine Logo
AtomicInteger
Code IndexAdd Tabnine to your IDE (free)

How to use
AtomicInteger
in
java.util.concurrent.atomic

Best Java code snippets using java.util.concurrent.atomic.AtomicInteger (Showing top 20 results out of 62,496)

origin: ReactiveX/RxJava

  @Override
  public void run() {
    if (wip.incrementAndGet() == 2) {
      emit();
      if (wip.decrementAndGet() == 0) {
        downstream.onComplete();
      }
    }
  }
}
origin: ReactiveX/RxJava

@Override
public void onComplete() {
  threadsRunning.incrementAndGet();
  System.out.println(">>> Busyobserver received onComplete");
  onComplete = true;
  int concurrentThreads = threadsRunning.get();
  int maxThreads = maxConcurrentThreads.get();
  if (concurrentThreads > maxThreads) {
    maxConcurrentThreads.compareAndSet(maxThreads, concurrentThreads);
  }
  threadsRunning.decrementAndGet();
}
origin: ReactiveX/RxJava

public FlowableAutoConnect(ConnectableFlowable<? extends T> source,
    int numberOfSubscribers,
    Consumer<? super Disposable> connection) {
  this.source = source;
  this.numberOfSubscribers = numberOfSubscribers;
  this.connection = connection;
  this.clients = new AtomicInteger();
}
origin: ReactiveX/RxJava

  @Override
  public void run() {
    c.decrementAndGet();
    while (c.get() != 0) { }
  }
});
origin: ReactiveX/RxJava

@Test
public void testUnsubscribeOnNestedTakeAndSyncInfiniteStream() throws InterruptedException {
  final AtomicInteger subscribeCounter = new AtomicInteger();
  final AtomicInteger sentEventCounter = new AtomicInteger();
  doTestUnsubscribeOnNestedTakeAndAsyncInfiniteStream(SYNC_INFINITE_OBSERVABLE_OF_EVENT(2, subscribeCounter, sentEventCounter), subscribeCounter);
  Thread.sleep(500);
  assertEquals(39, sentEventCounter.get());
}
origin: ReactiveX/RxJava

  @Override
  public void accept(Disposable d) {
    subscribed.getAndIncrement();
  }
})
origin: iluwatar/java-design-patterns

/**
 * Constructor
 */
public Oliphaunt() {
 id = counter.incrementAndGet();
 try {
  Thread.sleep(1000);
 } catch (InterruptedException e) {
  e.printStackTrace();
 }
}
origin: ReactiveX/RxJava

@Override
public void run() {
  counter.incrementAndGet();
  System.out.println("counter: " + counter.get());
  inner.schedule(this);
}
origin: ReactiveX/RxJava

@Override
public void onNext(Integer t) {
  // Consume after sleep for 1 ms
  try {
    Thread.sleep(1);
  } catch (InterruptedException e) {
    // ignored
  }
  if (counter.getAndIncrement() % 100 == 0) {
    System.out.println("testIssue2890NoStackoverflow -> " + counter.get());
  };
}
origin: ReactiveX/RxJava

  @Override
  public void onNext(Integer n) {
    if (depth.get() < MAX_STACK_DEPTH) {
      depth.set(Thread.currentThread().getStackTrace().length);
      a.onNext(n + 1);
    }
  }
});
origin: ReactiveX/RxJava

  @Override
  public void accept(Integer d) {
    dispose.set(d);
  }
});
origin: ReactiveX/RxJava

@Test
public void testUnsubscribeOnNestedTakeAndSyncInfiniteStream() throws InterruptedException {
  final AtomicInteger subscribeCounter = new AtomicInteger();
  final AtomicInteger sentEventCounter = new AtomicInteger();
  doTestUnsubscribeOnNestedTakeAndAsyncInfiniteStream(SYNC_INFINITE_OBSERVABLE_OF_EVENT(2, subscribeCounter, sentEventCounter), subscribeCounter);
  Thread.sleep(500);
  assertEquals(39, sentEventCounter.get());
}
origin: ReactiveX/RxJava

  @Override
  public void run() {
    c.decrementAndGet();
    while (c.get() != 0) { }
  }
});
origin: ReactiveX/RxJava

  @Override
  public void accept(Disposable d) {
    subscribed.getAndIncrement();
  }
})
origin: ReactiveX/RxJava

  @Override
  public void accept(Integer n) {
    count.incrementAndGet();
  }
});
origin: ReactiveX/RxJava

@Override
public void run() {
  counter.incrementAndGet();
  System.out.println("counter: " + counter.get());
  inner.schedule(this);
}
origin: ReactiveX/RxJava

  @Override
  public void accept(Integer v) {
    System.out.println("Value: " + v);
    lastValue.set(v);
  }
});
origin: ReactiveX/RxJava

@Test
public void testUnsubscribeOnNestedTakeAndAsyncInfiniteStream() throws InterruptedException {
  final AtomicInteger subscribeCounter = new AtomicInteger();
  final AtomicInteger sentEventCounter = new AtomicInteger();
  doTestUnsubscribeOnNestedTakeAndAsyncInfiniteStream(ASYNC_INFINITE_OBSERVABLE_OF_EVENT(2, subscribeCounter, sentEventCounter), subscribeCounter);
  Thread.sleep(500);
  assertEquals(39, sentEventCounter.get());
}
origin: ReactiveX/RxJava

  @Override
  public void run() {
    if (wip.incrementAndGet() == 2) {
      emit();
      if (wip.decrementAndGet() == 0) {
        downstream.onComplete();
      }
    }
  }
}
origin: ReactiveX/RxJava

@Override
public void onComplete() {
  threadsRunning.incrementAndGet();
  System.out.println(">>> Busyobserver received onComplete");
  onComplete = true;
  int concurrentThreads = threadsRunning.get();
  int maxThreads = maxConcurrentThreads.get();
  if (concurrentThreads > maxThreads) {
    maxConcurrentThreads.compareAndSet(maxThreads, concurrentThreads);
  }
  threadsRunning.decrementAndGet();
}
java.util.concurrent.atomicAtomicInteger

Javadoc

An int value that may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables. An AtomicInteger is used in applications such as atomically incremented counters, and cannot be used as a replacement for an java.lang.Integer. However, this class does extend Number to allow uniform access by tools and utilities that deal with numerically-based classes.

Most used methods

  • incrementAndGet
    Atomically increments by one the current value.
  • get
    Gets the current value.
  • <init>
    Creates a new AtomicInteger with the given initial value.
  • getAndIncrement
    Atomically increments by one the current value.
  • set
    Sets to the given value.
  • decrementAndGet
  • addAndGet
    Atomically adds the given value to the current value.
  • compareAndSet
    Atomically sets the value to the given updated value if the current value == the expected value.
  • intValue
    Returns the value of this AtomicInteger as an int.
  • getAndSet
    Atomically sets to the given value and returns the old value.
  • getAndDecrement
    Atomically decrements by one the current value.
  • getAndAdd
    Atomically adds the given value to the current value.
  • getAndDecrement,
  • getAndAdd,
  • toString,
  • lazySet,
  • longValue,
  • doubleValue,
  • updateAndGet,
  • getAndUpdate,
  • accumulateAndGet,
  • floatValue

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JList (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now