List of usage examples for java.lang Thread Thread
public Thread(String name)
From source file:Main.java
public static void main(String[] args) { new Thread(uncheck(() -> { Thread.sleep(1000L);/* w w w . j a v a 2 s . c o m*/ System.out.println("done"); })).start(); }
From source file:Main.java
public static void main(String args[]) { Thread t = new Thread(new ThreadDemo()); System.out.println("thread = " + t); t.start();//from www .ja v a 2s . c o m }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(Main::print); t.setDaemon(true);// ww w .j a v a 2 s .c o m t.start(); System.out.println("Exiting main method"); }
From source file:Main.java
public static void main(String[] args) { new Thread(Main::run).start(); new Thread(Main::run).start(); }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(Main::print); t.setDaemon(false);/*from ww w. j av a2 s.c o m*/ t.start(); System.out.println("Exiting main method"); }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(new MyThread()); t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { System.out.println(t + " throws exception: " + e); }//from ww w . j a v a 2 s . co m }); t.start(); }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(Main::run); t.start();//from w w w .j a v a 2s .com try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } t.interrupt(); }
From source file:Main.java
public static void main(String[] args) { Thread t = new Thread(new MyThread()); t.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { System.out.println(t + " throws exception: " + e); }/*from w w w. j av a2 s . c o m*/ }); t.start(); }
From source file:Main.java
public static void main(String[] args) { Thread t1 = new Thread(Main::print); t1.start();/*w w w . j av a 2 s . com*/ try { t1.join(); // "main" thread waits until t1 is terminated } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Done."); }
From source file:MainClass.java
public static void main(String[] args) { Thread thread = new Thread(new MyThread()); thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { System.out.println(t + " threw exception: " + e); }// ww w. j a v a2s .c o m }); thread.start(); }