// So what's a thread? A way to run tasks in parallel. // That is, simultaneously perform actions, something useful for // graphics and animation. // Create a subclass from class $Thread$. For code that you wish to // run in parallel, place all that code in a method called $run$. class Data extends Thread { int k; Data(int k) { this.k = k; } public void run() { for(int i=1;i<=10;i++) System.out.print(k); } } // class Data public class thread1 { public static void main(String args[]) { Data a = new Data(1); Data b = new Data(2); a.start(); b.start(); } } /* Output should mix up the order of 1s and 2s */