==
package Demo2;
/**
* Title:- Advanced Java_ Multi-threading Part 2 -- Basic Thread Synchronization - 1
* @author Dharmaraj.Net
* This example shows how implements Runnable interface and basic work of thread and run and start method
*/
class Runner implements Runnable {
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println("Hello" + "=" + i);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public class App {
public static void main(String[] args) {
Thread t1 = new Thread(new Runner());
Thread t2 = new Thread(new Runner());
t1.start();
t2.start();
}
}
No comments:
Post a Comment