hi friends,
i was running a program that has multiple threads with different priorities 5,6,2
C:\>java ThreadPri
start thread P
start thread Q
start thread R
end of main Thread
Thread p started
Thread[Thread-0,5,main]
from thread P: i =1
from thread P: i =2
from thread P: i =3
from thread P: i =4
Exit from P
Therad Q started
Thread[Thread-1,6,main]
from thread Q: j =1
from thread Q: j =2
from thread Q: j =3
from thread Q: j =4
Exit from Q
Therad R started
Thread[Thread-2,2,main]
from thread R: k =1
from thread R: k =2
from thread R: k =3
from thread R: k =4
Exit from R
I made some changes in program . now priorities are 5,7,2
C:\>java ThreadPri
start thread P
start thread Q
Therad Q started
Thread[Thread-1,7,main]
from thread Q: j =1
from thread Q: j =2
from thread Q: j =3
from thread Q: j =4
Exit from Q
start thread R
end of main Thread
Thread p started
Thread[Thread-0,5,main]
from thread P: i =1
from thread P: i =2
from thread P: i =3
from thread P: i =4
Exit from P
Therad R started
Thread[Thread-2,2,main]
from thread R: k =1
from thread R: k =2
from thread R: k =3
from thread R: k =4
Exit from R
why output is so different ? the pattern of priority is almost same in both cases ,
my opinion : program running correctly in second case
i was running a program that has multiple threads with different priorities 5,6,2
C:\>java ThreadPri
start thread P
start thread Q
start thread R
end of main Thread
Thread p started
Thread[Thread-0,5,main]
from thread P: i =1
from thread P: i =2
from thread P: i =3
from thread P: i =4
Exit from P
Therad Q started
Thread[Thread-1,6,main]
from thread Q: j =1
from thread Q: j =2
from thread Q: j =3
from thread Q: j =4
Exit from Q
Therad R started
Thread[Thread-2,2,main]
from thread R: k =1
from thread R: k =2
from thread R: k =3
from thread R: k =4
Exit from R
I made some changes in program . now priorities are 5,7,2
C:\>java ThreadPri
start thread P
start thread Q
Therad Q started
Thread[Thread-1,7,main]
from thread Q: j =1
from thread Q: j =2
from thread Q: j =3
from thread Q: j =4
Exit from Q
start thread R
end of main Thread
Thread p started
Thread[Thread-0,5,main]
from thread P: i =1
from thread P: i =2
from thread P: i =3
from thread P: i =4
Exit from P
Therad R started
Thread[Thread-2,2,main]
from thread R: k =1
from thread R: k =2
from thread R: k =3
from thread R: k =4
Exit from R
why output is so different ? the pattern of priority is almost same in both cases ,
my opinion : program running correctly in second case