开发者

External synchronization on ArrayBlockingQueue

The keyword synchronize does not appear in the source code of ArrayBlockingQueue. Does that mean I am free to use its intrinsic lock for "my own purposes"? Or 开发者_StackOverflow社区could this change in the future?


In general I'd shy away from it, since you could decide to do this, but then someone else on your team or a third party library (perhaps inadvertently) could also rely on having "exclusive" access to the monitor.

It might change in future, and you might not be the only one thinking about this now. If you can achieve what you want to do using private locks and monitors, or via a different system altogether (e.g. executing Futures), then that will be more robust.

(It's an interesting question though, and undoubtedly some people will find my opinion too defensive!)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜