Visualizing Thread-Safe Singletons in Java

Working in Java, we seldom have to create our handwritten singletons, for the existing frameworks like Spring creates these objects for us and maintains them. In enterprise applications, we get into framework disposal and let them create the singletons.

But it is interesting to know the singleton pattern and visualize the famous pattern in a multi-threaded environment. In this article, I will dive deep into this pattern with a multi-threaded environment view.

Porting From Nashorn: How To Handle JS Multi-Threading on Graalvm

Porting existing JavaScript code from Nashorn to GraalVM can be a challenge. This article focus on a multi-threading issue we got into when we ported SwiftMQ Stream scripts generated from Flow Director.Porting from Nashhorn

Javascript Is Single-Threaded

If you register an asynchronous callback on a Java class and this callback is invoked while you are still within the execution of the same JS script, you have multi-threaded access, even if you immediately schedule the processing of the callback in an event queue. Nashorn doesn’t check this, but GraalVM does and throws an exception. So any script with such callbacks will not work on GraalVM.

Is the Book ”Java Concurrency in Practice” Still Relevant in the Era of Java 12?

One of my readers, Shobhit, asked this question on my blog post about must-read advanced Java books: is the book "Java Concurrency in Practice" still relevant? I really liked the question and thought many Java programmers might have similar thoughts whenever someone recommends this popular Java read.

When this book was first published in 2006, the Java world was still not sure of about new concurrency changes made in Java 1.5. I think this was the first big attempt to improve Java's built-in support for multi-threading and concurrency.

Java SimpleDateFormat Is Not Simple

Formatting and parsing dates is a daily (painful) task. Every day, it gives us another headache.

A common way to format and parse dates in Java is using SimpleDateFormat. Here is a common class we can use.