public static void main(String[] args) throws InterruptedException, IOException { System.setProperty("java.net.preferIPv4Stack", "true"); TransactionProcessor transProcessor = new TransactionProcessor(); transProcessor.getId(); System.out.println( "Transaction Processor id " + transProcessor.id + " waiting to be activated"); new Thread() { public void run() { for (int i = 0; i < 4; i++) { transProcessor.updatePeers(transProcessor.id, 0); try { sleep(peersUpdateInterval); } catch (InterruptedException ex) { Logger.getLogger(TransactionProcessor.class.getName()).log(Level.SEVERE, null, ex); } } } }.start(); transProcessor.listenMulticast(); Thread t = new Thread(transProcessor); t.setUncaughtExceptionHandler(transProcessor.h); t.start(); while (true) { transProcessor.sendAliveSignal(); Thread.sleep(transProcessor.sendingInverval); } }
private void invokeOnExecutionThreadForTest(Runnable runnable) { executionThread = new Thread(runnable); executionThread.setUncaughtExceptionHandler( new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable e) { thrownByExecutionThread = e; } }); executionThread.start(); }