Forums Register Login

Do not synchronize doGet, doPost?

+Pie Number of slices to send: Send
While searching for some material on servlets, I came upon this
page. Do you think this is correct?

thanks,
Alex
+Pie Number of slices to send: Send
Absolutely. If you synchronize the method, then you serialize access to it. Now imagine what happens when 100 people hit the servlet at the same time.
+Pie Number of slices to send: Send
thanks Bear.
The reason I am asking is because a colegue of mine at work says that a server that supposed to return a unique number from a database sometimes returns the same number if server is hit twise. He says that making doGet() of the servlet synchronized will solve the problem. I say we need to make a synchronized block in the method and put code that accesses same resource in there.
+Pie Number of slices to send: Send
Your instinct is correct. The "lower down" you synchronize, the better as the critical section should be as tight/short as possible.
+Pie Number of slices to send: Send
thanks Bear.
The reason I am asking is because a colegue of mine at work says that a server that supposed to return a unique number from a database sometimes returns the same number if server is hit twise. He says that making doGet() of the servlet synchronized will solve the problem. I say we need to make a synchronized block in the method and put code that accesses same resource in there.
+Pie Number of slices to send: Send
sorry for double reply-post. thanks a lot.
+Pie Number of slices to send: Send
sorry for double reply-post. thanks a lot.
+Pie Number of slices to send: Send
sorry for double reply-post, for some reason I typed the reply and it did not show up in the thread. Had to post again. thanks a lot.
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2371 times.
Similar Threads
Question on generic methods
STRUTS: WHY???
junit classpath issue, I think
Constructors
The x900 effect ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:39:52.