Is the threading concurrency problem more pronunced in a multi-processor environment than in a single-processor environment?

Tim Rohaly

From the developer's point of view, the "concurrency problem" is simply that if your object is to be accessed from multiple threads, you need to take steps to ensure that your object is thread safe. Otherwise, your object may end up in an invalid state and may not behave as you expected. It makes no difference whether the accessor threads are running on the same processor or different processors; it is the internals of the JVM and the operating system that guarantee consistency of the address space across CPUs.

Because servlets by their nature are intended to be used in a multi-client environment, they should always either implement SingleThreadModel or be designed for thread safety. Note that making a servlet thread safe does not imply that the methods need to be declared as synchronized; synchronization is just one of the many techniques that can be used to impose thread safety.

See this FAQ for more information.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact