0

Is this proper use of threads

Please check the code below. Program prints numbers from 1-99 and than 99 times word "Hello". class Loader implements Runnable { public void run() { System.out.println("Hello"); } } class MyClass { public static void main(String[ ] args) { for (int i=1; i<100; i++) { System.out.println (i); Thread t = new Thread(new Loader()); t.start(); } } }

10th Jan 2017, 11:06 AM
Sasa Potic
Sasa Potic - avatar
1 Respuesta
+ 1
yes it is. Threads are used when you want multiple things to run in your program at the same time.
10th Jan 2017, 11:32 AM
Yousaf
Yousaf - avatar