ThreadLocal Resource Leak and WeakReference

后端 未结 7 1731
清酒与你
清酒与你 2020-12-30 03:12

My limited understanding of ThreadLocal is that it has resource leak issues. I gather this problem can be remedied through proper use of WeakReferences with ThreadLocal (al

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 04:03

    I'm guessing you're jumping through these hoops since SimpleDateFormat is not thread-safe.

    Whilst I'm aware I'm not solving your problem above, can I suggest you look at Joda for your date/time work ? Joda has a thread-safe date/time formatting mechanism. You won't be wasting your time learning the Joda API either, as it's the foundation for the new standard date/time API proposal.

提交回复
热议问题