Java Thread is like a virtual CPU that can execute your Java code — inside your Java application. when a Java application is started its main method is executed by the main thread - a special thread that is created by the Java VM to run your application. From inside your application, you can create and start more threads that can execute parts of your application code in parallel with the main thread.

Java threads are objects like any other Java object. Threads are instances of class java.lang.Threador instances of subclasses of this class. In addition to being objects, java threads can also execute code.

How to Create a Java Thread

Java lets you create a thread one of three ways:

  • By implementing the Runnable interface.
  • By implementing the Callable interface.
  • By extending the Thread.

Let’s have a look at how these ways help in implementing the Java thread.

#software-development #programming #software-engineering #java #concurrency

Java Concurrency: How to create a thread
1.10 GEEK