How to make java.util.Date thread-safe

前端 未结 4 511
无人及你
无人及你 2021-01-04 00:07

As far as i know that java.util.Date is mutable, so it\'s not thread-safe if multiple threads tried to accessing and modifying it. How do we use client-side loc

4条回答
  •  别那么骄傲
    2021-01-04 00:40

    There is no simple solution to create a thread-safe wrapper of Date class. The best way is to synchronize all usages of it's objects by using synchronized blocks.

提交回复
热议问题