List of usage examples for java.lang Thread join
public final void join() throws InterruptedException
From source file:Main2.java
public static void main(String arg[]) throws Exception { System.out.println("Main"); Thread t1 = new Thread() { public void run() { Main2.main(new String[] {}); }//from w w w . j ava2 s . co m }; t1.start(); t1.join(); System.out.println("Main again"); }
From source file:Main.java
public static void main(String[] args) throws Exception { Thread thread1 = new Thread(new TestThread(1)); Thread thread2 = new Thread(new TestThread(2)); thread1.start();// ww w . j a va 2s .com thread2.start(); thread1.join(); thread2.join(); }
From source file:PrepareProduction.java
public static void main(String[] args) throws Exception { List q = Collections.synchronizedList(new LinkedList<String>()); Thread p1 = new Thread(new PrepareProduction(q)); Thread c1 = new Thread(new DoProduction(q)); p1.start();/* w ww .j a v a 2 s.co m*/ c1.start(); p1.join(); c1.join(); }
From source file:PrepareProduction.java
public static void main(String[] args) throws Exception { BlockingQueue<String> q = new LinkedBlockingQueue<String>(); Thread p1 = new Thread(new PrepareProduction(q)); Thread c1 = new Thread(new DoProduction(q)); p1.start();/*from w ww . j av a 2 s . co m*/ c1.start(); p1.join(); c1.join(); }
From source file:RunMuleClient.java
/** * @param args/*from ww w .j av a 2 s.c o m*/ * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length == 2) { MAX = Integer.parseInt(args[0]); NUM = Integer.parseInt(args[1]); } //String path = "./conf/mule-telnet-sample-client.xml"; String path = "./mule-telnet-sample-client.xml"; client = new MuleClient(path); client.getMuleContext().start(); Thread[] list = new Thread[NUM]; for (int i = 0; i < NUM; i++) { list[i] = new Thread(new RunMuleClient()); } for (Thread th : list) { th.start(); } for (Thread th : list) { th.join(); } client.getMuleContext().dispose(); client.dispose(); log(); return; }
From source file:Main.java
public static void main(String args[]) throws Exception { Semaphore sem = new Semaphore(1, true); Thread thrdA = new Thread(new MyThread(sem, "Message 1")); Thread thrdB = new Thread(new MyThread(sem, "Message 2")); thrdA.start();// w w w.jav a2 s . co m thrdB.start(); thrdA.join(); thrdB.join(); }
From source file:com.eaio.uuid.UUIDPerformance.java
public static void main(String[] args) { Thread[] threads = new Thread[Runtime.getRuntime().availableProcessors()]; for (int i = 0; i < threads.length; ++i) { threads[i] = new Thread(new UUIDRunnable(count / threads.length)); }/* ww w. j a va 2s .com*/ StopWatch watch = new StopWatch(); watch.start(); for (Thread t : threads) { t.start(); } for (Thread t : threads) { try { t.join(); } catch (InterruptedException e) { // Moo } } watch.stop(); System.out.println(watch.getTime()); }
From source file:net.semanticmetadata.lire.solr.AddImages.java
public static void main(String[] args) throws IOException, InterruptedException { BitSampling.readHashFunctions();//from w w w . j a v a 2s. com LinkedList<Thread> threads = new LinkedList<Thread>(); for (int j = 10; j < 21; j++) { final int tz = j; Thread t = new Thread() { @Override public void run() { try { List<File> files = FileUtils .getAllImageFiles(new File("D:\\DataSets\\WIPO-US\\jpg_us_trim\\" + tz), true); int count = 0; BufferedWriter br = new BufferedWriter(new FileWriter("add-us-" + tz + ".xml", false)); br.write("<add>\n"); for (Iterator<File> iterator = files.iterator(); iterator.hasNext();) { File file = iterator.next(); br.write(createAddDoc(file).toString()); count++; // if (count % 1000 == 0) System.out.print('.'); } br.write("</add>\n"); br.close(); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }; t.start(); threads.add(t); } for (Iterator<Thread> iterator = threads.iterator(); iterator.hasNext();) { Thread next = iterator.next(); next.join(); } }
From source file:Main.java
public static void main(String args[]) throws Exception { Semaphore sem = new Semaphore(1, true); Thread thrdA = new Thread(new SyncOutput(sem, "Message 1")); Thread thrdB = new Thread(new SyncOutput(sem, "Message 2!")); thrdA.start();//from w w w . java2s . c o m thrdB.start(); thrdA.join(); thrdB.join(); }
From source file:jsonclient.JsonClient.java
public static void main(String args[]) { int EPS = 1;/*from ww w .j a va 2s .c om*/ List<Place> countries = new ArrayList<Place>(); List<Thread> threads = new ArrayList<Thread>(); Country country; countries = getCountries(); //CountrySearcher countrySearcher = null; Iterator<Place> itrCountry = countries.iterator(); ExecutorService exec = Executors.newFixedThreadPool(4); while (itrCountry.hasNext()) { country = new Country(itrCountry.next()); CountrySearcher cs = new CountrySearcher(country, EPS); threads.add(cs.thread); exec.execute(cs); } exec.shutdown(); for (Thread th : threads) try { th.join(); } catch (InterruptedException ex) { Logger.getLogger(JsonClient.class.getName()).log(Level.SEVERE, null, ex); } }