3

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 could this change in the future?

2
  • I couldn't find the class AbstractBlockingQueue in JDK6. What's its fully qualified name? Commented Jun 23, 2011 at 9:04
  • 1
    @Boris: Sorry, that was a mistake. See my updated question. Commented Jun 23, 2011 at 9:26

1 Answer 1

3

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!)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.