List of usage examples for java.lang Thread start
public synchronized void start()
From source file:Main.java
public static void main(String[] args) { // Create a Thread object Thread t = new Thread(Main::print); // Start the thread t.start(); }
From source file:MainClass.java
public static void main(String args[]) { map = new WeakHashMap(); map.put("A", "B"); Runnable runner = new Runnable() { public void run() { while (map.containsKey("A")) { try { Thread.sleep(1000); System.gc();/*from w w w .ja v a 2s. com*/ } catch (InterruptedException ignored) { } System.out.println("Has A"); System.gc(); } } }; Thread t = new Thread(runner); t.start(); System.out.println("Main waiting"); try { t.join(); } catch (InterruptedException ignored) { } System.gc(); }
From source file:MyThread.java
public static void main(String args[]) { System.out.println("Main thread starting."); Thread thrd = new Thread(new MyThread()); thrd.start(); try {//from w ww .j a v a2 s . c o m thrd.join(); } catch (InterruptedException exc) { System.out.println("Main thread interrupted."); } System.out.println("Main thread ending."); }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(Main::print); t.setDaemon(true);/*w w w . j a v a 2s . c om*/ t.start(); System.out.println("Exiting main method"); }
From source file:MyThread.java
public static void main(String args[]) { System.out.println("Main thread starting."); MyThread mt = new MyThread(); Thread newThrd = new Thread(mt); newThrd.start(); do {/*from w w w .java 2s. co m*/ System.out.println("In main thread."); try { Thread.sleep(250); } catch (InterruptedException exc) { System.out.println("Main thread interrupted."); } } while (mt.count != 5); System.out.println("Main thread ending."); }
From source file:Main.java
public static void main(String[] args) { int port = Integer.parseInt(args[0]); try {/*from w ww . j a va 2s. c om*/ Thread t = new Main(port); t.start(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(Main::print); t.setDaemon(false);/*from w w w . ja va2 s .co m*/ t.start(); System.out.println("Exiting main method"); }
From source file:com.cottsoft.thrift.framework.server.RunServer.java
public static void main(String[] args) { Thread thread = new RunServer(); thread.start(); }
From source file:MainClass.java
public static void main(String[] args) { int port = Integer.parseInt(args[0]); try {//from w w w . ja v a 2 s. c o m Thread t = new MainClass(port); t.start(); } catch (IOException e) { e.printStackTrace(); } }
From source file:GeneralInterrupt.java
public static void main(String[] args) { GeneralInterrupt si = new GeneralInterrupt(); Thread t = new Thread(si); t.start(); try {/*w ww. jav a 2 s .c o m*/ Thread.sleep(2000); } catch (InterruptedException x) { } System.out.println("in main() - interrupting other thread"); t.interrupt(); System.out.println("in main() - leaving"); }