Java examples for Thread:Thread Operation
Starting a Background Task
public class Main { public static void main(String[] args) { Thread backgroundThread = new Thread(new Runnable() { public void run() { System.out.println(Thread.currentThread().getName() + ": is Running in the background"); }//from w w w . j av a 2 s .c o m }, "Background Thread"); System.out.println("Start"); backgroundThread.start(); for (int i = 0; i < 10; i++) { System.out.println(Thread.currentThread().getName() + ": is counting " + i); } System.out.println("Done"); } }