Home » Tag Archives: Concurrency (page 2)

Tag Archives: Concurrency

Asynchronous timeouts with CompletableFuture

java-logo

One day I was rewriting poorly implemented multi-threaded code that was blocking at some point on Future.get():                   public void serve() throws InterruptedException, ExecutionException, TimeoutException { final Future<Response> responseFuture = asyncCode(); final Response response = responseFuture.get(1, SECONDS); send(response); } private void send(Response response) { //... } This was actually an Akka application ...

Read More »

Playing With Java Concurrency

java-logo

Recently I needed to transform some filet that each has a list (array) of objects in JSON format to files that each has separated lines of the same data (objects). It was a one time task and simple one. I did the reading and writing using some feature of Java nio. I used GSON in the simplest way. One thread ...

Read More »

Thread local storage in Java

java-logo

One of the rarely known features among developers is Thread-local storage.  The idea is simple and need for it comes in  scenarios where we need data that is … well local for the thread. If we have two threads we that refer to the same global variable but we wanna them to have separate value independently initialized of each other. ...

Read More »

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 »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.