Multiple Threads calling static helper method

前端 未结 7 655
孤街浪徒
孤街浪徒 2021-02-08 03:05

I have a web application running on Tomcat.

There are several calculations that need to be done on multiple places in the web application. Can I make those calculations

7条回答
  •  清歌不尽
    2021-02-08 03:44

    For the first part: Yes, these calls are independent and run in parallel when called by different threads.

    For the last part: Use synchronize blocks on the concurrent object, a dummy object or class object. Be aware of cascaded synchronize blocks. They can lead into dead locks when acquired in different order.

提交回复
热议问题