posted 23 years ago
Hi Tamanna,
I also added 2 lines, but I got different outputs,
Test thread from amethod
Test threadfrom amethod after start
Test thread from main
Test thread 0 1 2 3
The reason is , main() is a seperate thread, and we start another another thread from amethod, so there are 2 threads with same priority.
which thread will run first depends on the system. if amethod thread starts first, the output will be like your output.
In my case I think the main thread got invoked first so I got the this output.(a 's value didn't have 0..3 from main)
If I yield() from the main the output is like this,
Test thread from amethod
Test threadfrom amethod after start
Test thread 0 1 2 3 from run
Test thread 0 1 2 3 from main
Correct me, if I am wrong,
Vanitha.