Binary Semaphore Tutorial and Example

Last Updated:

A semaphore is a counter that protects the access to one or more shared resources. In this tutorial, we will learn how to use the …

Restarting threads using UncaughtExceptionHandler

Last Updated:

1. UncaughtExceptionHandler Java applications have two kind of exceptions – checked exceptions and unchecked exceptions. Checked exceptions must be specified in the throws clause of …

Java Compare and Swap Example – CAS Algorithm

Last Updated:

One of the best additions in java 5 was Atomic operations supported in classes such as AtomicInteger, AtomicLong etc. These classes help you in minimizing …

Java Concurrency – Thread Safety?

Last Updated:

Defining thread safety is surprisingly tricky. A quick Google search turns up numerous “definitions” like these: Thread-safe code is code that will work even if …

Java concurrency – CountDownLatch Example

Last Updated:

As per java docs, CountDownLatch is a synchronization aid that allows one or more threads to wait until a set of operations being performed in …

Java ConcurrentHashMap Best Practices

Last Updated:

The ConcurrentHashMap is very similar to the HashMap class, except that ConcurrentHashMap offers internally maintained concurrency. It means you do not need to have synchronized …

Java executor framework tutorial and best practices

Last Updated:

Java executor framework (java.util.concurrent.Executor), released with the JDK 5 is used to run the Runnable objects without creating new threads every time and mostly re-using …

Java Deadlock Example and Solution

Last Updated:

Learn to create a deadlock in Java, programmatically, with an example. Also learn to detect deadlock and how to solve a deadlock situation in sourcecode.

HowToDoInJava

A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.