Ensure Main Method Exit at the End

We can achieve this by isAlive() and join() methods of Thread class. isAlive() is not great at doing this task. So, we will be using join() method. Threadd class — implements Runnable :  class Threadd implements Runnable{Thread t;String name; Threadd(){name = “how”;t = new Thread(this,name);System.out.println(“This is thread”);t.start();} public void run() {for(int i=0;i<20;i++){System.out.println(“This is run method”);try{Thread.sleep(100);}catch(InterruptedException … Read more