Tilmeld dig vores faglige nyhedsbrev
Givet følgende:
public static void main(String[] args) { final Thread t2 = new Thread(){ public void run(){ try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("t2 done"); } }; Thread t1 = new Thread(){ public void run(){ try { t2.join(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("t1 done"); } }; t2.start(); t1.start(); }
Hvad printes sandsynligvis når main køres?