Java: Synchronizing on primitives?

前端 未结 10 1829
小鲜肉
小鲜肉 2021-02-01 21:13

In our system, we have a method that will do some work when it\'s called with a certain ID:

public void doWork(long id) { /* ... */ }

Now, this

10条回答
  •  遥遥无期
    2021-02-01 21:45

    Premature optimization is the root of evil

    Try it with a (synchronized) map.

    Maybe if it grows too big, you can clear its content at regular intervals.

提交回复
热议问题