Hi all,
I'm tryin to figure out how threads pass through methods without interfering with each other.
Bill Brogden kindly answered a previosu question related to this by saying that each
thread gets its own instance of the method to play with.
Is that how threads usually work? I thought a thread could get paused halfway through a method and then another thread could come through and cock things up? Is that not right? And thats why we have the synchronised keyword - to make sure that another thread - with access to all the same values - doesnt take, manipulate and replace values written by another thread.
I just dont get how say 50 simultaneous users dont mess up with each others data if all fifty of them are stomping about the same instance! Where does synchronisation come into it?
Alot of that examples I have seen have made short references to the need for synchronisation, but then very few examples actually have any synchronisation at all. They maybe show a token example straight out of the
java tutorial.
I guess my question is:
With so many possible requests all flying about the place, and with lots of methods doing things - where does synchronisation fit into it all? When do I need to synchronise and went do I not need to? All these threads are freaking me out!!! Waaaahh
Thanks everyone. This is a great site and
servlets are really cool.
Take care
Simon