The following code creates a new costum Thread
and waits for the thread to end and only then the main thread gets active again.
- I don't quite understand how it works. Why doesn't
mythread.wait();
get called immediatlly? Why not using
Thread.join()
instead?public static void main(String[] args) {
Thread mythread = new MyThread("hello"); mythread.start(); synchronized (mythread) { try { mythread.wait(); } catch (InterruptedException e) { } } }