The NEW state

A Java thread is in the NEW state if it is created but not started (the thread constructor creates threads in the NEW state). This is its state until the start() method is invoked. The code bundled with this book contains several snippets of code that reveal this state via different construction techniques, including lambdas. For brevity, the following is just one of these constructions:

public class NewThread {

public void newThread() {
Thread t = new Thread(() -> {});
System.out.println("NewThread: " + t.getState()); // NEW
}
}

NewThread nt = new NewThread();
nt.newThread();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.179.100