ThreadLocal is arguably the easiest way to render a stateful class thread-safe, or to encapsulate non-thread-safe classes so they can safely be used in multithreaded env. ThreadLocal can be used to implement per-thread-singleton, or per-thread-conext.
singleton Scopes the bean definition to a single instance per Spring container (default). prototype Allows a bean to be instantiated any number of times (once per use). request Scopes a bean definition to an HTTP request. Only valid when used with a web capable Spring context (such as with Spring MVC). session Scopes a bean definition to an HTTP session. Only valid when used with a webcapableSpring context (such as with Spring MVC). global-session Scopes a bean definition to a global HTTP session. Only valid when used in a portlet context.
Comments
Post a Comment