Home » Tag Archives: Concurrency (page 2)

Tag Archives: Concurrency

Converting between Completablefuture and Observable

java-logo

CompletableFuture<T> from Java 8 is an advanced abstraction over a promise that value of type T will be available in the future. Observable<T> is quite similar, but it promises arbitrary number of items in the future, from 0 to infinity. These two representations of asynchronous results are quite similar to the point where Observable with just one item can be ...

Read More »

ExecutorService – 10 tips and tricks

java-logo

ExecutorService abstraction has been around since Java 5. We are talking about 2004 here. Just a quick reminder: both Java 5 and 6 are no longer supported, Java 7 won’t be in half a year. The reason I’m bringing this up is that many Java programmers still don’t fully understand how ExecutorService works. There are many places to learn that, ...

Read More »

Multithreading and Concurrency Interview Questions and Answers – The ULTIMATE List (PDF Download)

java-logo

EDITORIAL NOTE: Concurrency is always a challenge for developers and writing concurrent programs can be extremely hard. There is a number of things that could potentially blow up and the complexity of systems rises considerably when concurrency is introduced. However, the ability to write robust concurrent programs is a great tool in a developer’s belt and can help build sophisticated, ...

Read More »

Beyond Thread Pools: Java Concurrency is Not as Bad as You Think

java-logo

Apache Hadoop, Apache Spark, Akka, Java 8 streams and Quasar: The classic use cases to the newest concurrency approaches for Java developers There’s a lot of chatter going around about newer concepts in concurrency, yet many developers haven’t had a chance to wrap their heads around them yet. In this post we’ll go through the things you need to know about ...

Read More »

How to Use Callable and FutureTask

java-logo

Introduction Since Java 1.5 there has been a new set of objects under java.util.concurrent.  This package has a number of different classes including thread queues.  I could have used those when I was programming with Java 1.2!  When I started looking at the new toys I became hesitant.  What is this Callable thing and what is the Future?  It turns ...

Read More »

Java Concurrency Tutorial – Locking: Intrinsic locks

java-logo

In previous posts we reviewed some of the main risks of sharing data between different threads (like atomicity and visibility) and how to design classes in order to be shared safely (thread-safe designs). In many situations though, we will need to share mutable data, where some threads will write and others will act as readers. It may be the case ...

Read More »

EJB 3.x : Lifecycle and Concurrency models (part 2)

java-interview-questions-answers

This is the second post of the two part series. The first part covered the life cycle and the concurrency behavior of Stateful and Stateless EJBs. I’ll cover Singleton EJBs in this post. The Singleton pattern is arguably the most used (some times misused!) pattern out there.         Java EE frees us from writing explicit code (like one on the above ...

Read More »

Java Concurrency Tutorial – Thread-safe designs

java-logo

After reviewing what the main risks are when dealing with concurrent programs (like atomicity or visibility), we will go through some class designs that will help us prevent the aforementioned bugs. Some of these designs result in the construction of thread-safe objects, allowing us to share them safely between threads. As an example, we will consider immutable and stateless objects. ...

Read More »

Java Concurrency Tutorial – Visibility between threads

java-logo

When sharing an object’s state between different threads, other issues besides atomicity come into play. One of them is visibility. The key fact is that without synchronization, instructions are not guaranteed to be executed in the order in which they appear in your source code. This won’t affect the result in a single-threaded program but, in a multi-threaded program, it ...

Read More »

Java Concurrency Tutorial – Atomicity and race conditions

java-logo

Atomicity is one of the key concepts in multi-threaded programs. We say a set of actions is atomic if they all execute as a single operation, in an indivisible manner. Taking for granted that a set of actions in a multi-threaded program will be executed serially may lead to incorrect results. The reason is due to thread interference, which means ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close