Home » Tag Archives: Concurrency (page 6)

Tag Archives: Concurrency

5 Things You Didn’t Know About Synchronization in Java and Scala

java-logo

Practically all server applications require some sort of synchronization between multiple threads. Most of the synchronization work is done for us at the framework level, such as by our web server, DB client or messaging framework. Java and Scala provide a multitude of components to write solid multi-threaded applications. These include object pools, concurrent collections, advanced locks, execution contexts etc.. To ...

Read More »

Java FutureTask Example Program

java-logo

Sometime back I wrote a post about Java Callable Future interfaces that we can use to get the concurrent processing benefits of threads as well as they are capable of returning value to the calling program. FutureTask is base concrete implementation of Future interface and provides asynchronous processing. It contains the methods to start and cancel a task and also ...

Read More »

Lock Less Java Object Pool

java-logo

It has been a while since I wrote anything, I have been busy with my new job that involves doing some interesting work on performance tuning. One of the challenges is to reduce object creation during the critical part of the application. Garbage Collection hiccups has been a main pain point in java for some time, although java has improved over time the ...

Read More »

Invoking Async method call using Future object in Spring

spring-interview-questions-answers

The next example will demonstrate an async method call inside the Spring container. Why do we need async method calls? In some cases we don’t really know if replay is expected or when a result supposed to be delivered back. Traditional way In the Java EE world of handling async calls is using Queue/Topic. We could do the same in ...

Read More »

Experiment with ConcurrentHashmap

java-logo

I am investigating a memory issue in one of my recent projects where data is kept in memory for fast access, but the memory footprint of application is very high. This application was heavily using CHM(i.e Concurrenthashmap), so no brainier guess was required that CHM was the issue. I did a memory profiling session to find how much memory CHM was really taking. ...

Read More »

Five advanced Java Synchronizers you probably don’t know

java-logo

Besides the common synchronize which is based in the lock bit that every Java object has, you have more sophisticated synchronizers in java, such as: Semaphore – Use the concept of a permit to indicate a max number of allowed threads in a place. When you use the value 1, the behavior its similar to synchronize, also called binary semaphore. There is however a big difference ...

Read More »

Java 8: CompletableFuture in action

java-logo

After thoroughly exploring CompletableFuture API in Java 8 we are prepared to write a simplistic web crawler. We solved similar problem already using ExecutorCompletionService, Guava ListenableFuture and Scala/Akka. I choose the same problem so that it’s easy to compare approaches and implementation techniques. First we shall define a simple, blocking method to download the contents of a single URL:   ...

Read More »

Java 8: Definitive guide to CompletableFuture

java-logo

Java 8 is coming so it’s time to study new features. While Java 7 and Java 6 were rather minor releases, version 8 will be a big step forward. Maybe even too big? Today I will give you a thorough explanation of new abstraction in JDK 8 – CompletableFuture<T>. As you all know Java 8 will hopefully be released in ...

Read More »

Synchronising Multithreaded Integration Tests revisited

java-interview-questions-answers

I recently stumbled upon an articleSynchronising Multithreaded Integration Tests on Captain Debug’s Blog. That post emphasizes the problem of designing integration tests involving class under test running business logic asynchronously. This contrived example was given (I stripped some comments):               public class ThreadWrapper { public void doWork() { Thread thread = new Thread() { ...

Read More »

Why a synchronized StringBuffer was never a good idea

java-logo

Introduction StringBuffer is a synchronized class for mutable strings.  The main problem with making it synchronized is that It was usually used as a local variable so making it synchronized just made it slower. It was never a good idea to use it in a multi-threaded way.  This problem is that developers assumed that methods which used StringBuffer were themselves ...

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.