Locking basics
The tutorial chapter on concurrency introduces the locking basics as well as ThreadSafeList and SwingThreadProxyEventList .
Keep in mind that you should also lock your root list during
construction of list pipelines, when multiple threads are used
concurrently.
ThreadedMatcherEditor
to do...
CompositeList and locking
A CompositeList is composed of multiple source EventLists.
All contained EventLists must use the same ListEventPublisher and
ReadWriteLock as the CompositeList, particularly if this list is to be used by multiple threads
concurrently. To construct an EventList that shares the publisher and lock with the CompositeList,
method CompositeList#createMemberList() can be used.
CollectionList and locking
CollectionList uses an instance of type CollectionList.Model
to determine the list of children for each list element of the source
list. If the model returns an EventList of children, it must use the
same lock and ListEventPublisher as the CollectionList (and its source
list).
DebugList
If you are using multiple threads and you want to debug some things, you can use the DebugList as a drop-in replacement for BasicEventList . It must be configured to check for the kind of errors you're interested in. The two types of errors it can report are:
setLockCheckingEnabled(true) will ensure that each read/write is guarded by the appropriate lock.
getSanctionedReaderThreads().add(Thread.currentThread()); and getSanctionedWriterThreads().add(Thread.currentThread());
indicates that the current Thread (and ONLY the current Thread) should
ever read/write from the given DebugList. This is useful when you want
to guarantee things like "only my data loader Thread writes into the
list pipeline" or "only the Swing EDT reads from the list pipeline",
etc, etc.
|