Java Interview Cheat Sheet (Java 17+)
Goal: One consistent, modern syntax reference for Java, DSA & backend interviews. 1. Comparator Integer.compare(a,b); // ⭐ Ascending (avoid a-b overflow) Integer.compare(b,a); // ⭐ Descending a.
Search for a command to run...
Series
Goal: One consistent, modern syntax reference for Java, DSA & backend interviews. 1. Comparator Integer.compare(a,b); // ⭐ Ascending (avoid a-b overflow) Integer.compare(b,a); // ⭐ Descending a.
Executors Important Methods Shutdown Initiates orderly shutdown of the ExecutorService AFter calling shutdown, Executor will not accept new task submission. Already submitted tasks, will continue to execute AwaitTermination It's an optional fun...

Brief Executors provides Factory methods which we can use to create Thread Pool Executor. Threase are present in java.util.concurrent package. Fixed ThreadPoolExecutor newFixedThreadPool method creates a thread pool executor with a fixed no. of ...

Status of submitted task public class Main { public static void main(String[] args) { ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(1,1,10, TimeUnit.HOURS, new ArrayBlockingQueue<>(10), Executors.defaultThreadFa...

Thread Pool It's a collection of threads (aka workers), which are available to perform the submitted tasks. Once task completed, worker thread get back to Thread Pool and wait for new task to assigned. Means threads can be reused. Advantages of...

Concurrency Types Concurrency can be achieved using 2 ways Lock based Mechanism Synchronized Reentrant Stamped ReadWrite Semaphores Lock Free Mechanism CAS Operation (Compare-and Swap) AtomicInteger AtomicBoolean AtomicLong AtomicReference...
