我想在Java中实现多线程的延迟初始化.
我有一些类似的代码:
class Foo {
private Helper helper = null;
public Helper getHelper() {
if (helper == null) {
Helper h;
synchronized(this) {
h = helper;
if (h == null)
synchronized (this) {
h = new Helper();
} // release inner synchronization lock
helper = h;
}
}
return helper;
}
// other functions and members...
}
Run Code Online (Sandbox Code Playgroud)
而且我得到了"Double-Checked Locking is Broken"声明.
我怎么解决这个问题?
我正在使用Jackson来序列化/反序列化JSON对象.
我有一个Study对象的以下JSON :
{
"studyId": 324,
"patientId": 12,
"patient": {
"name": "John",
"lastName": "Doe"
}
}
Run Code Online (Sandbox Code Playgroud)
更新:不幸的是,JSON结构无法修改.这是问题的一部分.
我想将对象反序列化为以下类:
public class Study {
Integer studyId;
Patient patient;
}
Run Code Online (Sandbox Code Playgroud)
和
public class Patient {
Integer patientId;
String name;
String lastName;
}
Run Code Online (Sandbox Code Playgroud)
是否可以patientId在Patient对象中包含属性?
我能够反序列化patient对象到Patient类(对应name和lastName性质),但不能包含patientId属性.
有任何想法吗?
这是场景:
实现这一目标的正确方法是什么?
我的客户应该是他们项目帐户的所有者,并为我创建一个具有完全访问权限的用户?或者可以从我的帐户管理应用程序,但为每个应用程序设置不同的帐单信息?
希望你能帮忙.提前致谢!