Write me a code that prints "success" (after a thread.join()) if a thread has been successfull (all instructions have been made without errors, with a Runnable instance).
public class MyThread extends Thread { Runnable runnable = new Runnable(){ @Override public void run() { System.out.println("success"); } }; public void run() { runnable.run(); System.out.println("done"); } } public class Test { public static void main(String[] args){ MyThread thread = new MyThread(); thread.start(); try { thread.join(); System.out.println("success"); } catch(Exception e){ System.out.println("error"); } } }