Guys when I try 2 threads instances(for counting upto 10 ) using runnable interface I get output where in t1 is completely executed n then t2 ... While in tutorial t1.10 t2.10 t1.9 t2. 9 t1.8 t1.7 like that | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Guys when I try 2 threads instances(for counting upto 10 ) using runnable interface I get output where in t1 is completely executed n then t2 ... While in tutorial t1.10 t2.10 t1.9 t2. 9 t1.8 t1.7 like that

What's the problem

2nd Aug 2016, 7:36 AM
Umed Jadhav
Umed Jadhav - avatar
5 Respostas
+ 2
Maybe thread run very quick. Let's try call Thread.sleep(1000);
2nd Aug 2016, 10:40 AM
WPimpong
WPimpong - avatar
+ 1
The output of two threads depends on many factors, such as architecture and thread priority. The most important one being the JVM, which gives no guarantee at all about the order of threads. So it is likely that the output of a program running on two threads is different on different computers.
14th Sep 2016, 11:14 PM
Kerem AdıgĆ¼zel
Kerem AdıgĆ¼zel - avatar
0
okk but I followed the guy of tutorial but we r having different op ?? y is that ?? He n have both have same for loop conditions
2nd Aug 2016, 7:51 AM
Umed Jadhav
Umed Jadhav - avatar
0
I'll try that wachirakorn:)
2nd Aug 2016, 4:50 PM
Umed Jadhav
Umed Jadhav - avatar
0
@ kerem r u saying that each individual thread is running on separate core that's y the problem is occurring
15th Sep 2016, 2:15 AM
Umed Jadhav
Umed Jadhav - avatar