1 19 20 package org.netbeans.core.startup; 21 22 import org.openide.util.Exceptions; 23 24 28 final class TopThreadGroup extends ThreadGroup implements Runnable { 29 30 private String [] args; 31 32 private boolean finished; 33 34 39 public TopThreadGroup(String name, String [] args) { 40 super(name); 41 this.args = args; 42 } 43 44 59 public TopThreadGroup(ThreadGroup parent, String name) { 60 super(parent, name); 61 } 62 63 public void uncaughtException(Thread t, Throwable e) { 64 if (!(e instanceof ThreadDeath )) { 65 if (e instanceof VirtualMachineError ) { 66 e.printStackTrace(); 68 } 69 System.err.flush(); 70 Exceptions.printStackTrace(e); 71 } 72 else { 73 super.uncaughtException(t, e); 74 } 75 } 76 77 public synchronized void start () throws InterruptedException { 78 Thread t = new Thread (this, this, "main"); t.start (); 80 81 while (!finished) { 82 wait (); 83 } 84 } 85 86 public void run() { 87 try { 88 Main.start (args); 89 } catch (Throwable t) { 90 Exceptions.printStackTrace(t); 92 try { 94 Thread.sleep(10000); 95 } catch (InterruptedException x) { 96 Exceptions.printStackTrace(x); 97 } 98 System.exit(2); 99 } finally { 100 synchronized (this) { 101 finished = true; 102 notify (); 103 } 104 } 105 } 106 } 107 | Popular Tags |