Java examples for Thread:Thread
Create a simple thread
public class SimpleMain { public static void main(String[] args) { Thread thread = new Thread(new A()); thread.start();//from w w w .j a v a 2s .c om thread.interrupt(); } } class A implements Runnable { @Override public void run() { for (int i = 0; i < 10; i++) { try { System.out.println("Produced:" + i); Thread.sleep(5000); } catch (Exception e) { System.out.println(e); } } } }