What is new In Project Loom

Reading Time: 2 minutes

Project loom is an OpenJDK project that aims to enable “easy-to-use, high-throughput lightweight concurrency and new programming models on the Java platform.”

Before Project Loom

As of now, we know that the basic unit of concurrency is Thread. Thread map 1-1 to kernel Threads and these threads work well but they also have certain limitations which are as follows:-

  • Expensive To Create:- Below are a few points why threads are costly to create.
  • They are expensive to create because they are not correctly used by the engineers
  • There are too many and there is a ton of context switching.
  • There is a competition for the same set of resources.

To OverCome This Situation We have

  • Thread-Pooling:- a group of worker threads that are waiting for the job and reused many times, Example of Java Thread Pool

Advantage Of ThreadPool:- Better performance It saves time because there is no need to create a new thread.

Disadvantage Of ThreadPool:- With more threads, the code becomes difficult to debug and maintain.

Real-Time Usage Of ThreadPool:-It is used in Servlet and JSP where the container creates a thread pool to process the request.

Why Use Project Loom

Project loom aims to drastically reduce the efforts of writing, maintaining, and observing high-throughput concurrent applications that make the best use of available hardware when the requirement is to scale many concurrent execution units.

Contribution Of Project Loom

  • Virtual Threads:- Virtual Threads is just like a Threads but they are cheap to create and block .below are the example of how to create threads
Thread t = Thread.startVirtualThread(()-> {....});
  • Continuation:- Every continuation has an entry point and a yield point. because it is a representation in the code of the execution flow

The advantage Of Project Loom

  • is that it gives us a tool to write non-blocking code in the “blocking” style.

The disadvantage Of Project Loom

  • is that it does not give us a replacement for concurrency libraries

Conclusion

in this blog, we got to know about a glimpse of Project Loom, and for more details, you can visit https://openjdk.java.net/projects/loom/


Knoldus-blog-footer-image

Written by 

Hi Guys This is Jatin, I am working as Java Consultant in Knoldus Software LLP. I like to explore new technology and learn from the java community blogs.