Home » Tag Archives: Concurrency

Tag Archives: Concurrency

Agrona’s Threadsafe Offheap Buffers

java-logo

This blog post continues my ongoing series on the Agrona library by explaining how we offer easy access to offheap memory for threadsafe operations. I should probably caveat before we move on that this is a fairly advanced topic and I don’t attempt to explain concepts such as memory barriers – merely outline the features of the API. The deficiencies ...

Read More »

A Case Study in Analysing Latency: Lock vs Synchronized

java-logo

In particular in this post we will discuss: Garbage created by java.concurrent.Lock Comparing Lock to synchronized How to measure latency programatically The impact of contention on Lock and synchronized The impact of co-ordinated omission on latency tests Back to one of my favourite topics garbage creation / allocation. See my previous posts (e.g. First rule of performance optimisation and Revisiting the First Rule of ...

Read More »

Dealing with Interruptions

java-logo

I was just watching the VJUG interview with Heinz Kabutz which inspired me to write a post about Interruptions. By the way I would recommend subscribing to the VJUG YouTube channel – very informative indeed. Heinz is always good value and it’s difficult to watch any of his presentations without learning a lot. He raised the topic of how to deal ...

Read More »

Farewell to Asynchronous Code

java-interview-questions-answers

Quasar is a library that adds true lightweight threads (fibers) to the JVM. These are very cheap and very fast – in fact, fibers behave just like Erlang processes or Go goroutines – and allow you to write simple blocking code while enjoying the same performance benefits of complex asynchronous code. In this post we’ll learn how to transform any asynchronous, ...

Read More »

Shooting yourself in the foot with Random number generators

java-logo

This is not going to be one of the posts explaining how a random number generator is not so random after all. So those of you expecting a guideline for how to hack a slot machine, move along, nothing to see here. Instead, it is a post about one of the not-so-uncommon lock contention issues, hidden inside random number generators ...

Read More »

CompletableFuture can’t be interrupted

java-logo

I wrote a lot about InterruptedException and interrupting threads already. In short if you call Future.cancel() not inly given Future will terminate pending get(), but also it will try to interrupt underlying thread. This is a pretty important feature that enables better thread pool utilization. I also wrote to always prefer CompletableFuture over standard Future. It turns out the more ...

Read More »

Java Concurrency Tutorial – Locking: Explicit locks

java-logo

1. Introduction In many cases, using implicit locking is enough. Other times, we will need more complex functionalities. In such cases, java.util.concurrent.locks package provides us with lock objects. When it comes to memory synchronization, the internal mechanism of these locks is the same as with implicit locks. The difference is that explicit locks offer additional features. The main advantages or ...

Read More »

Java8 Multi-threading ForkJoinPool: Dealing with exceptions

java-logo

One of the main motivations behind the introduction of Java8 lambdas was the ability to be able to use multicores as easily as possible (see Mastering Lambdas: Java Programming in a Multicore World).  By simply changing your code from collection.stream()... to collection.parallelStream()... you have instant multi-threading at your disposal which brings with it all the CPU power on your machine. ...

Read More »

Fork/Join Framework vs. Parallel Streams vs. ExecutorService: The Ultimate Fork/Join Benchmark

java-logo

How does the Fork/Join framework act under different configurations? Just like the upcoming episode of Star Wars, there has been a lot of excitement mixed with criticism around Java 8 parallelism. The syntactic sugar of parallel streams brought some hype almost like the new lightsaber we’ve seen in the trailer. With many ways now to do parallelism in Java, we ...

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.