Browse by Topic

Popular

Latest

Latest Java Posts

Illustration of two threads waiting for a single lock held by another thread, representing the Java synchronized keyword mutual exclusion.
Java

How the Java synchronized Keyword Protects Shared State

Understand how Java's synchronized keyword protects shared state with intrinsic locks and visibility guarantees, including synchronized methods, blocks, and when to choose ReentrantLock.

Java concurrencythread safetysynchronized blocksintrinsic locks
Illustration of a Java daemon thread running in the background while the JVM main thread completes and exits
Java

Java Daemon Thread: Behavior, Creation, and Use Cases

java daemon thread: Learn how Java daemon threads work, how to create them with setDaemon(true), and when background tasks should or should not use them.

daemon threadJVM lifecyclethread lifecyclebackground tasks
Diagram showing Java thread state transitions from NEW to TERMINATED with monitoring tools.
Java

Java Thread States: Lifecycle and Monitoring

Understand the six Java thread states, how threads transition between them, and how to observe states with getState(), thread dumps, and monitoring tools.

ThreadsConcurrencyThread LifecycleThread Dump
Diagram showing the six states of a Java thread lifecycle with arrows for transitions between states.
Java

Java Thread Lifecycle: States and Transitions

Understand the six Java thread states, how threads transition between them, and how to monitor and manage thread lifecycle in production.

Thread StatesConcurrencyMultithreadingThread Management
A thread being interrupted with a flag, representing Java's cooperative cancellation mechanism.
Java

Java Thread Interrupt: How It Works and How to Use It

Learn how the Java thread interrupt mechanism works, how to handle InterruptedException, and how to use interrupt flags for cooperative cancellation in real applications.

threadingconcurrencyinterruptmultithreading
Illustration of a main thread waiting for a worker thread to complete using Thread.join()
Java

Java Thread Join: Waiting for Threads to Finish

java thread join: Learn how Thread.join() blocks the calling thread until a worker finishes, including timeout variants, interrupt handling, and common pitfalls.

Thread.joinJava concurrencymultithreadingthread synchronization
Illustration of a Java thread pausing with a clock and interruption signal, representing Thread.sleep behavior.
Java

Java Thread.sleep: Usage, Pitfalls, and Alternatives

Understand how Thread.sleep works in Java, handle InterruptedException correctly, avoid common pitfalls, and learn better alternatives for concurrency.

Thread.sleepConcurrencyInterruptedExceptionJava Concurrency
Diagram showing Thread.start() creating a new thread versus Thread.run() executing in the main thread
Java

Java start vs run: Thread Behavior Explained

Understand the difference between Thread.start() and Thread.run() in Java, why calling run() directly skips new thread creation, and when each approach is appropriate.

JavaThreadConcurrencyRunnable
Diagram showing the difference between calling run() directly on the calling thread versus start() creating a new thread in Java.
Java

Java Thread run() vs start(): What's the Difference?

Calling Thread.run() directly executes on the current thread; Thread.start() creates a new thread. Learn the difference, common pitfalls, and when ExecutorService is the better choice.

JavaThreadsConcurrencyRunnable
Diagram showing a main thread calling Thread.start() which creates a new thread executing run() concurrently.
Java

Java Thread Start: How Thread.start() Works

Understand what happens when you call Thread.start() in Java, why run() doesn't start a new thread, and how to handle lifecycle, errors, and thread pools.

ThreadConcurrencyMultithreadingJava