when is treelock used?
843804Jan 13 2005 — edited Jan 14 2005I'm working on a layout manager. I took a look at the source for java.awt.GridBagLayout, and I notice they synchronize on the parent container's treelock. However, it isn't used consistently -- but only within one method.
I would like to know, under which circumstances is required to synchronize on this lock? I would like to understand what it is in GridBagLayout.GetLayoutInfo() that requires this synchronization, as opposed to all other methods which don't synchronize (but operate on the same data structures). Obviously, to answer this question you would have to take a look at the Java source.
I tried searching around:
The javadoc for Container.getTreeLock() says: "Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations." Vague. Doesn't resolve the above question.
http://today.java.net/pub/a/today/2003/08/14/layouts.html. "Synchronizing on the object returned by the container's getTreeLock method ensures thread safety while performing the layout." Still doesn't resolve the above question.
http://forum.java.sun.com/thread.jspa?forumID=5&threadID=11406. Similar question to my own. No answer.
http://forum.java.sun.com/thread.jspa?forumID=5&threadID=9663. Intelligent sounding answer from mtj, but it's a crock. Either way it doesn't resolve the above question.
Etc.