Gaurang Rathod wrote:Hello ranchers.
.......
Answer given is "ABC" and rightly so.
Why is answer not "123"?
How could main thread change myRunnable object's instance variable s[] ?
Thanks advance.
Why would you think it should be 123. What happens after you have invoked sleep in your main() method? Would the two threads interleave? What happens if you increase or decrease the sleep interval? Does that affect your output in anyway ( besides the time taken to execute the program)?
Chan.