开发者

SynchronizedSet in apache commons

开发者 https://www.devze.com 2023-03-04 15:36 出处:网络
Why is开发者_如何学Go there Apache\'s Synchronized Set when we have Collection\'s SynchronizedSet?

Why is开发者_如何学Go there Apache's Synchronized Set when we have Collection's SynchronizedSet?

Is it better in any way?


It depends on what you want to do. Apache's synchronized set allows you to get the underlying set. It is probably provide for consistency. The Collections method is standard.

You might consider using one of the concurrent sets like Collections.setFromMap(new ConcurrentHashMap()), CopyOnWriteArraySet or ConcurrentSkipListSet


My guess is because it allows you to specify a custom lock object.

The constructor is protected but you can subclass it and pass a custom lock.

0

精彩评论

暂无评论...
验证码 换一张
取 消