So, how would one synchronize parts of a , servlet? using the synchronized key word?
john smith
Ranch Hand
Joined: Mar 04, 2004
Posts: 75
posted
0
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?
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
1
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Question involving servlet output and synchronization