Anil Kumar Gola

Java/JVM

Embracing Virtual Threads in Spring Boot

In this blog, we will see how we can take leverage of project loom virtual threads in spring-boot. We will also do some load testing with the help of JMeter and see how response time is for both virtual threads and normal threads. Let’s quickly setup our spring boot project. <?xml version="1.0" encoding="UTF-8"?> ...

22-May-2023

Java/JVM

Structured Task Scope – New Concurrency Model in JVM

Since the advent of virtual threads in Java, we have had a new and nice concurrency model introduced as StructuredTaskScope. We will see some patterns in this new model. We need to know that with virtual threads, since they are very cheap, we don’t need to pool them. Also, we need to know that a virtual thread can pull its stack from...

15-May-2023

Java/JVM

Say No to H2, Yes to Test-Container

Developers get confused over the priority of unit test cases and integration test cases. Though both are important, when we are building services for clients, we are on a tight schedule, so completing the development is itself a challenge, let alone writing test cases. I always strive to write test cases, irrespective of the time we...

06-May-2023

Java/JVM

Java Project Loom – Launching 10 million threads (Part 2)

In the previous blog, we discussed a detailed overview of Project Loom. Now it’s time for some code. If you have not read about part 2 of this series, please check it out here: Let us see how we can create virtual threads in Java. Thread.ofVirtual().unstarted(() -> System.out.println("Thread is not started")); ...

15-Mar-2023

Java/JVM

Java Project Loom – Virtual Threads (Part 1)

This JEP No 425 is something I am waiting for with bated breath. It’s a new notion that has been added to the concurrent APIs of JDK 19. It’s in the preview stage, and soon it will be a permanent feature in JDK in the coming few releases. Virtual Threads are light weight that reduce the effort of writing, maintaining and...

13-Mar-2023

Java/JVM

Distributed Locks in Spring-boot Microservice Environment

Suppose we are in an environment where only one instance is running in production. We want to do an account update and synchronise the transaction where we are doing the update. This can easily be achieved with the help of Reentrant Locks api’s of java, as shown below. @Service @RequiredArgsConstructor @Slf4j public class...

22-Feb-2023

Java/JVM

Spring State Machine

State Machine Overview Spring state machine is a spring-module that allows us to describe well known, well understood transitions from one state to another. You have probably built a million state machines in your life if you have ever done any kind of programming. For example any kind of if-then-else statement at some point will...

09-Dec-2022