Java Programming Tutorials

Java programming tutorials with many code examples!

Java volatile and atomic operations

Problem:

How to use Java volatile and atomic operations to write lock-free code? These are two fundamental concepts in Java concurrency and understanding both of them is required to write correct, thread-safe code.

Read More

Share with the World!

Java ReentrantLock

Problem:

How to use Java ReentrantLock instead of old-school synchronization on lock object? In this post we’re going to show an example with basic features of ReentrantLock.

Read More

Share with the World!

Java synchronize static

Problem:

How to synchronize concurrent modifications of static data in Java? In this post we’re going to solution to this common, multi-threaded, problem. Read on!

Read More

Share with the World!

Java synchronized object

Problem:

How to guarantee thread-safely in concurrent Java code? In this post we’re going to show how to synchronize blocks of code using two different methods.

Read More

Share with the World!

Java synchronized method

Problem:

How to safely modify data in multi-threaded Java code? This problem can be solved in many ways. In this post we’re going to show how to use Java synchronized method to guarantee code correctness.

Read More

Share with the World!

Java Thread pause

Problem:

How to pause Java Threads? In this post we are going to show three ways to do that – using Thread class and TimeUnit from java.util.concurrent. Read on!

Read More

Share with the World!

Java Thread Join Example

Problem:

How to Java Thread join to do simple synchronization of threads? In this post we show an example where one thread waits for another to clean up after it. Read on!

Read More

Share with the World!
Pages:1234