Java synchronization and performance in an aspect

后端 未结 5 693
失恋的感觉
失恋的感觉 2021-01-05 18:14

I just realized that I need to synchronize a significant amount of data collection code in an aspect but performance is a real concern. If performance degrades too much my t

5条回答
  •  一整个雨季
    2021-01-05 19:06

    If you compile the aspect into the application then you will have basically no performance hit, if you do it at runtime (load-type weaving) then you will see a performance hit.

    If you have each aspect be perinstance then it may reduce the need for synchronization.

    You should have as little synchronization as possible, for as short a time as possible, to reduce any problems.

    If possible you may want to share as little state as possible between threads, keeping as much local as possible, to reduce any deadlock problems.

    More information would lead to a better answer btw. :)

提交回复
热议问题