I am not sure about this ... methods have local variables that are not declared on heap. Each thread will have its own set of variable. I tried to create a code to prove my point but it did not work out well.
EDITED.... Finally, i was able to create a code ...
the output is Thread b1 prints 1-101 & then goes into wait. Thread b2 prints 1-101 & then goes into wait. But notifies just before wait Thread b1 resumes & prints 102-150. Notifies All before exiting Synchronized Thread b2 resumes & prints 102-150.
Hope it helps.
Edited again ... in run method if you declasre I as int than also it will give same result [ July 20, 2008: Message edited by: Milan Sutaria ] [ July 20, 2008: Message edited by: Milan Sutaria ]
which shows that each Thread is create new copy of local variable each time it not makes any difference for static method.. ya if you take this j as member variable then as per ilan Sutaria case will be different.. might this example will clear you drought very clary
Ok, it�s more clear for me now. After see this examples code i will assume that in all methods (static or not) local variables are created in the stack not in the heap, and for this reason, there are no problem about concurrent access with this local variables.