Can someone help me understand how threads function in java.
I have a main class:
public static void main(String[] args) {
Runnable r = new TestThread();
new Thread(r).start();
executor.execute(r);
System.out.println("Hey the thread has ended")
}
and a thread class:
public class TestThread implements Runnable {
public class TestThread() {
sleep(20000);
}
@Override
public void run() {
// TODO Auto-generated method stub
}
}
How can I get the phrase:"Hey the thread has ended" without having to wait while the thread sleeps?