List of usage examples for java.lang Thread Thread
public Thread(ThreadGroup group, Runnable target, String name)
From source file:io.s4.zeno.SiteTest.java
public static void main(String[] arg) throws JSONException, KeeperException, IOException, InterruptedException { PropertyConfigurator.configure("log4j.properties"); String name = arg[0];/* w ww .j ava 2 s . c o m*/ String zkaddr = arg[1]; String zkbase = arg[2]; String specStr = arg[3]; ConfigMap spec = new JSONConfigMap(specStr); ZooKeeper zk = new ZooKeeper(zkaddr, 3000, zkhandler); zookeeper = new ZooKeeperHelper(zk, 5, 5000); zkpath = new ZKPaths(zkbase); ZooKeeperInfo zkinfo = new ZooKeeperInfo(); zkinfo.zookeeper = zookeeper; zkinfo.zkpath = zkpath; zkinfo.taskHolder = new NonblockingLockset(zookeeper, zkpath.taskBase); zkinfo.partsHolder = new NonblockingLockset(zookeeper, zkpath.partsBase); zkinfo.standbySequence = new DistributedSequence(zookeeper, zkpath.standbyBase); final Site site = new Site(name, spec); ZKCluster cluster = new ZKCluster(zookeeper, zkpath); ZKJobList jobList = new ZKJobList(site, zkinfo); ZKPartList partList = new ZKPartList(site, zkinfo); SiteInitializer init = new SiteInitializer(); site.setCluster(cluster); site.setJobList(jobList); site.setPartList(partList); site.setInitializer(init); class ZenoThreadGroup extends ThreadGroup { public ZenoThreadGroup() { super("ZenoThreadGroup"); } public void uncaughtException(Thread t, Throwable e) { System.out.println("ZENOTHREADGROUP CAUGHT AND EXCEPTION FROM THREAD " + t + ". SO EXITING. DETAILS:" + e + "\nCAUSED BY: " + e.getCause() + "\n"); e.printStackTrace(); System.exit(1); } } Thread t = new Thread(new ZenoThreadGroup(), new Runnable() { public void run() { site.start(); } }, "zenorunthread"); t.start(); System.out.println(); t.join(); }