/images/avatar.jpg

David Vlijmincx | Senior software developer

I am a Senior developer, Public speaker, Java blogger, and Author

Extending the Thread class in Java

Introduction Using Java, there are two ways to implement a thread. You can implement the Runnable interface, or you can extend the Thread class. In this tutorial, we will delve into the latter approach of extending the Thread class to create threads. Extending the thread class Extending the Thread class is done by adding extends Thread after the class name. By extending the Thread class you can override the run method from this class.

Future with Virtual threads

Introduction We are gonna look at how to use virtual threads with a future. Doing this requires only a couple lines of code. A future makes it is easy to return a value from a (virtual) thread. Future with a virtual thread Creating a future from a virtual thread is done by using the newVirtualThreadPerTaskExecutor. Since Java 21 the ExecutorService now implements the autocloseable interface which means that we can use it with the try-with-resource statement.

Helidon quickstart with an IDE

Introduction Helidon is a collection of libraries for writing microservices. It fully supports GraalVM, Jakarta EE, and Microprofile. While the quickstart on the Helidon site already tells you how to create a project, I wanted to offer you a few great alternatives. This tutorial will look at creating a Helidon project using the online starter and IntelliJ. I will also cover how to create a run profile for your project, so you don't have to use the command line every time.

Scoped Values in Java

Scoped values are a new way to share data between threads without using method parameters. They also use less memory compared to Thread local variables. What is a Scoped Value Scoped values are a new addition to the Java language. I was first introduced as an incubating feature in Java 20 as JEP 429, as a preview feature in Java 21 in JEP 446, and is currently in the second preview round in Java 22 as JEP 464 .

Lifecycle methods JUnit 5 and 4

Introduction In this post, I am going to show you how you can run methods before and after a test method runs. Junit offers 4 different annotations you can use to decide when a method runs during the lifecycle of a test. One annotation lets you run a method before all the other tests are started while another runs every time before a test is started. The annotations differ between JUnit 5 and 4, I will show how both of them work starting with JUnit 5.