Home » Tag Archives: Concurrency (page 6)

Tag Archives: Concurrency

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 »

Inadvertent Recursion Protection with Java ThreadLocals

java-logo

Now here’s a little trick for those of you hacking around with third-party tools, trying to extend them without fully understanding them (yet!). Assume the following situation: You want to extend a library that exposes a hierarchical data model (let’s assume you want to extend Apache Jackrabbit) That library internally checks access rights before accessing any nodes of the content ...

Read More »

Detecting Java Threads in Deadlock with Groovy and JMX

groovy-logo

Unfortunately, Java applications taking advantage of multiple threads can at times run into the dreaded deadlock condition. Fortunately, the Java Platform makes deadlock detection relatively easy. In fact, the built-in (since J2SE 5) ThreadMXBean (a PlatformManagedObject exposed via JMX) makes this information available to any client that ‘speaks JMX‘ via the findDeadlockedThreads() and findMonitorDeadlockThreads() methods. General ‘JMX clients’ such as ...

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.