> From: John Smith [mailto:tomcat.ran...@gmail.com] 
> Subject: Concurrency - Servlet created instances accessing static classes

> Assume the following:
> 1. Servlet receives an HTTP POST request. doPost(...) is called.
> 2. doPost(..) instantiates class X with each request

First terminology problem: class X isn't instantiated here, an object of type 
class X is instantiated.

> 3. Class X calls a static method of class Y

Second terminology problem: classes don't make calls, threads do.

> Assuming I have no synchronization in the method signature or body of Y,
> there is a danger of concurrency issues or thread safety issues. Many
> instances of X can call Y's static method at the same time, causing BAD
> THINGS to happen.

The type, state, or condition of X is irrelevant; it's the fact that multiple 
threads may be calling Y's static method concurrently that is the issue.  
Whether or not that is safe is entirely dependent on the code inside Y.

 - Chuck


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to