以下是来自Java EE教程的单例会话bean示例:
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Singleton
public class ExampleSingletonBean {
private String state;
@Lock(LockType.READ)
public String getState() {
return state;
}
@Lock(LockType.WRITE)
public void setState(String newState) {
state = newState;
}
}
private String state
字段如何变得不稳定?应用程序服务器如何保证此引用永远不会针对不同的同时HTTP请求进行本地线程缓存?