Adeel Ansari wrote:- First of all, you don't need total1 and total2 in MyThread1 class. Just one total will work
- And you may not require name either. As I can see, you are using to make conditions between total1 and total2
The output may be partial for the one but not the other
Or
The output may not be partial for the one and but for the other
Or
The output may not be partial for both
Or
The output may be partial for both
It depends if the run() method would manage to complete itself and able to assign the values to total1, andr total2, before the main thread invoke getTotal(), then none of them would be partial.
where partial = not computed complete list
Hi Adeel,
Thanks for your reply..
I thought that using the same variable total for both threads is causing the problem. Introduction of Variables total1 and total2 were simply a part of the experimentation to check if that was really the issue!
Anyway, i understood your ans. But if getTotal() appears AFTER calling the run() method in the code sequence, why is it that the execution of the run method is not complete by then?
Thanks.