/* Multithreaded example. There are two ways to create multithreading. One inherits the thread class and overwrites the Run method in thread, and calls its Start method. The function of the Startt method is to open the thread and call the Run method. The purpose of the replication run method is to store the custom code in the Run method and let the thread run. */class demo extends thread{ public void run () { for (int x =0; x <40;x++) { system.out.println ("Demo run ..." +x); } } }class threaddemo{ public static void main (String []args] { demo d = new demo (); d.start ();//Open the thread and execute the thread's Run method. If it is D.run (), then only the Run method is allowed, and no multithreading is turned on. for (int i = 0;i<40;i++) { system.out.println (" HELLOWOLRD----"+i); } The main thread of the //, executed in parallel with start-open threads. }}
This article from "Sima" blog, reproduced please contact the author!
Java Multithreaded Example