我有一个休息网络服务:
@Path("/tranreq")
public class TranscriptRequesterResource {
private static final Gson GSON = new Gson();
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getTranscriptRequests() {
// use GSON here
}
}
将Gson对象设为静态最终常量并将其重用于多线程请求的每个人是否安全?
答案 0 :(得分:1)
我过去曾以这种方式使用过GSON而没有任何问题。一个例子似乎很多。