Home » Tag Archives: Concurrency (page 8)

Tag Archives: Concurrency

Java Deadlock Example – How to analyze deadlock situation

java-logo

Deadlock is a programming situation where two or more threads are blocked forever, this situation arises with at least two threads and two or more resources. Here I have written a simple program that will cause deadlock scenario and then we will see how to analyze it.               Java Deadlock Example package com.journaldev.threads; public ...

Read More »

Waiting for the right moment – in integration testing

java-interview-questions-answers

When you have to test multi-threaded programs, there is always the need to wait until the system arrives at a particular state, at which point the test can verify that the proper state has been reached. The usual way to do it is to insert a ‘probe’ in the system which will signal a synchronization primitive (like a Semaphore) and ...

Read More »

Can synchronization be optimised away?

java-logo

Overview There is a common misconception that because the JIT is smart and synchronization can be eliminated for an object which is only local to a method that there is no performance impact.             A test comparing StringBuffer and StringBuilder These two classes do basically the same thing except one is synchronized (StringBuffer) and the ...

Read More »

Devoxx 2012: Java 8 Lambda and Parallelism, Part 1

devoxx-logo

Overview Devoxx, the biggest vendor-independent Java conference in the world, took place in Atwerp, Belgium on 12 – 16 November. This year it was bigger yet, reaching 3400 attendees from 40 different countries. As last year, I and a small group of colleagues from SAP were there and enjoyed it a lot. After the impressive dance of Nao robots and ...

Read More »

Parallelization of a simple use case explained

scala-logo

Some time ago a friend of mine asked me about the possibilities of speeding up the following process: they are generating some data in two stages, reading from a database and processing the results. Reading takes approximately 70% of time and processing takes the remaining 30%. Unfortunately they cannot simply load the whole data into memory, thus they split reading ...

Read More »

Investigating Deadlocks – Part 5: Using Explicit Locking

java-logo

In my last blog I looked at fixing my broken, deadlocking balance transfer sample code using both Java’s traditional synchronized keyword and lock ordering. There is, however, an alternative method known as explicit locking. The idea here of calling a locking mechanism explicit rather than implicit is that the explicit means that it is not part of the Java language and that classes have ...

Read More »

Investigating Deadlocks – Part 4: Fixing the Code

java-logo

In the last in this short series of blogs in which I’ve been talking about analysing deadlocks, I’m going to fix my BadTransferOperation code. If you’ve seen the other blogs in this series, you’ll know that in order to get to this point I’ve created the demo code that deadlocks, shown how to get hold of a thread dump and then analysed ...

Read More »

Investigating Deadlocks – Part 3

java-logo

In my previous two blogs in this series, part 1 and part 2, I’ve demonstrated how to create a piece of bad code that deadlocks and then used this code to show three ways of taking a thread dump. In this blog I’m going to analyze the thread dump to figure out what when wrong. The discussion below refers to ...

Read More »

Java deadlock troubleshooting and resolution

java-logo

One of the great things about JavaOne annual conferences is the presentation of several technical and troubleshooting labs presented by subject matter experts. One of these labs did especially capture my attention this year: “HOL6500 – Finding And Solving Java Deadlocks ”,  presented by Java Champion Heinz Kabutz . This is one of the best presentations I have seen on this subject. I ...

Read More »

Investigating Deadlocks – Part 2

java-logo

One of the most important requirements when investigating deadlocks is actually having a deadlock to investigate. In my last blog I wrote some code called DeadlockDemo that used a bunch of threads to transfer random amounts between a list of bank accounts before grinding to a halt in a deadlock. This blog runs that code to demonstrates a few ways of obtaining ...

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