June 2018
Intermediate to advanced
408 pages
11h 23m
English
Threads are objects in the Java language. They can be created using the following mechanisms:
There are two ways to create a Runnable object. The first way is to create a class that implements the Runnable interface as follows:
public class ThreadExample { public static void main(String[] args) { Thread t = new Thread(new MyThread()); t.start(); }}class MyThread implements Runnable { private static final Logger LOGGER = Logger.getLogger(MyThread.class); public void run() { //perform some task LOGGER.info("Hello from thread..."); }}
Before Java 8, we only had this way to create a Runnable object. But since Java 8, we can create ...
Read now
Unlock full access