@@ -0,0 +1,1159 @@
+// Create a thread by implementing Runnable.%0A%0Aclass MyThread implements Runnable %7B%0A%09int count;%0A%09String thrdName;%0A%09%0A%09MyThread(String name) %7B%0A%09%09count = 0;%0A%09%09thrdName = name;%0A%09%7D%0A%09%0A%09// Entry point of thread.%0A%09public void run() %7B%0A%09%09System.out.println(thrdName + %22 starting.%22);%0A%09%09try %7B%0A%09%09%09do %7B%0A%09%09%09%09Thread.sleep(100);%0A%09%09%09%09System.out.println(%22In %22 + thrdName + %22, count is %22 + count);%0A%09%09%09%09count++;%0A%09%09%09%7D while(count %3C 10);%0A%09%09%7D%0A%09%09catch(InterruptedException exc) %7B%0A%09%09%09System.out.println(thrdName + %22 interrupted.%22);%0A%09%09%7D%0A%09%09System.out.println(thrdName + %22 terminating.%22);%0A%09%7D%0A%7D%0A%0Aclass UseThreads %7B%0A%09public static void main(String args%5B%5D) %7B%0A%09%09System.out.println(%22Main thread starting.%22);%0A%09%09%0A%09%09// First, construct a MyThread object.%0A%09%09MyThread mt = new MyThread(%22Child #1%22);%0A%09%09%0A%09%09// Next, construct a thread from that object.%0A%09%09Thread newThrd = new Thread(mt);%0A%09%09%0A%09%09// Finally, start execution of the thread.%0A%09%09newThrd.start();%0A%09%09%0A%09%09do %7B%0A%09%09%09System.out.print(%22.%22);%0A%09%09%09try %7B%0A%09%09%09%09Thread.sleep(10);%0A%09%09%09%7D%0A%09%09%09catch(InterruptedException exc) %7B%0A%09%09%09%09System.out.println(%22Main thread interrupted.%22);%0A%09%09%09%7D%0A%09%09%7D while (mt.count != 10);%0A%09%09%0A%09%09System.out.println(%22Main thread ending.%22);%0A%09%7D%0A%7D%0A

Create a thread by implementing Runnable