Category: 05. Java Concurrency

  • newFixedThreadPool Method

    A fixed thread pool can be obtainted by calling the static newFixedThreadPool() method of Executors class. Syntax where Example The following TestThread program shows usage of newFixedThreadPool method in thread based environment. This will produce the following result. Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your…

  • ScheduledExecutorService Interface

    A java.util.concurrent.ScheduledExecutorService interface is a subinterface of ExecutorService interface, and supports future and/or periodic execution of tasks. ScheduledExecutorService Methods Sr.No. Method & Description 1 <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)Creates and executes a ScheduledFuture that becomes enabled after the given delay. 2 ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)Creates and executes a one-shot…

  • ExecutorService Interface

    A java.util.concurrent.ExecutorService interface is a subinterface of Executor interface, and adds features to manage the lifecycle, both of the individual tasks and of the executor itself. ExecutorService Methods Sr.No. Method & Description 1 boolean awaitTermination(long timeout, TimeUnit unit)Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current…

  • Executor Interface

    A java.util.concurrent.Executor interface is a simple interface to support launching new tasks. ExecutorService Methods Sr.No. Method & Description 1 void execute(Runnable command)Executes the given command at some time in the future. Example The following TestThread program shows usage of Executor interface in thread based environment. This will produce the following result. Output

  • AtomicReferenceArray Class

    A java.util.concurrent.atomic.AtomicReferenceArray class provides operations on underlying reference array that can be read and written atomically, and also contains advanced atomic operations. AtomicReferenceArray supports atomic operations on underlying reference array variable. It have get and set methods that work like reads and writes on volatile variables. That is, a set has a happens-before relationship with…

  • AtomicLongArray Class

    A java.util.concurrent.atomic.AtomicLongArray class provides operations on underlying long array that can be read and written atomically, and also contains advanced atomic operations. AtomicLongArray supports atomic operations on underlying long array variable. It have get and set methods that work like reads and writes on volatile variables. That is, a set has a happens-before relationship with…

  • AtomicIntegerArray Class

    A java.util.concurrent.atomic.AtomicIntegerArray class provides operations on underlying int array that can be read and written atomically, and also contains advanced atomic operations. AtomicIntegerArray supports atomic operations on underlying int array variable. It have get and set methods that work like reads and writes on volatile variables. That is, a set has a happens-before relationship with…

  • AtomicReference Class

    A java.util.concurrent.atomic.AtomicReference class provides operations on underlying object reference that can be read and written atomically, and also contains advanced atomic operations. AtomicReference supports atomic operations on underlying object reference variable. It have get and set methods that work like reads and writes on volatile variables. That is, a set has a happens-before relationship with…

  • AtomicBoolean Class

    A java.util.concurrent.atomic.AtomicBoolean class provides operations on underlying boolean value that can be read and written atomically, and also contains advanced atomic operations. AtomicBoolean supports atomic operations on underlying boolean variable. It have get and set methods that work like reads and writes on volatile variables. That is, a set has a happens-before relationship with any…

  • AtomicLong Class

    A java.util.concurrent.atomic.AtomicLong class provides operations on underlying long value that can be read and written atomically, and also contains advanced atomic operations. AtomicLong supports atomic operations on underlying long variable. It have get and set methods that work like reads and writes on volatile variables. That is, a set has a happens-before relationship with any…