Java Multithreaded Part 2 - Implementing Runnable

preview_player
Показать описание
How to create a java multithreaded program implementing runnable interface
Рекомендации по теме
Комментарии
Автор

package

public class RunnableThread implements Runnable {

public void run() {
System.out.println("Start of thread: " +

try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}

System.out.println("End of thread: " +

}

public static void main(String[] args) {

System.out.println("Start of Main: ");

for (int i=0; i<10; i++){
Thread t = new Thread(new RunnableThread());
t.start();

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}

}
System.out.println("End of Main: ");


}

}

ghoshalacademy