So, how would one synchronize parts of a , servlet? using the synchronized key word?
Joined: Mar 04, 2004
Don't use synchronized at all in servlets. Thread management is up to the container. You can get some way to the same behaviour that synchronized would give you by having your servlet implement the (now deprecated) interface javax.servlet.SingleThreadModel. I'd be curious to know why you need this functionality?
Author and all-around good cowpoke
Joined: Mar 22, 2000
If your servlet has an instance variable that must only be accessed by one request Thread at a time, of course you use synchronized code. When designing a servlet one normally strives to reduce or eliminate the necessity for synchronized access, but sometimes it is necessary. Bill