Can this Java singleton get rebuilt repeatedly in WebSphere 6?

后端 未结 10 958
清酒与你
清酒与你 2021-02-13 13:26

I\'m trying to track down an issue in our system and the following code worries me. The following occurs in our doPost() method in the primary servlet (names have been changed

10条回答
  •  南笙
    南笙 (楼主)
    2021-02-13 13:39

    No - the static initialization of the instance will only ever be done once. Two things to consider:

    • This is not thread-safe (the instance is not "published" to main memory)
    • Your firstTime method is probably called multiple times, unless properly synchronized

提交回复
热议问题