If we want to restrict our servlet being accessed by multiple Thread, we can implement the SingleThreadModel interface to our servlet, why we can't use synchronized key word here?
Thanks in Advanced!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
No, of course not. Not allowing multiple threads to access code doesn't make the code thread-safe. It just prevents it from being an issue.
So let's say you're lazy and just synchronize your servlet code instead of writing it properly in the first place. What happens when two clients hit the servlet at the same time? What about ten clients? What about 100? 1000? 10,000?