Package jade.util
Class SynchList
- java.lang.Object
-
- jade.util.RWLock
-
- jade.util.SynchList
-
public class SynchList extends RWLock
Implementation of a list of objects providing methods to synchronize threads acting on the list in such a way to prevent concurrent modifications (addition/remotion of elements) and concurrent scanning/modification. Concurrent scannings are allowed instead.- Author:
- Giovanni Caire - TILab
-
-
Constructor Summary
Constructors Constructor Description SynchList()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidonWriteEnd()This placeholder method is called every time a thread actually releases the protected resource with writing privileges (this means that, in case of multiple recursive unlocking by the same thread, this method is called only the last time).protected voidonWriteStart()This placeholder method is called every time a thread actually acquires the protected resource with writing privileges (this means that, in case of multiple recursive locking by the same thread, this method is called only the first time).ListstartModifying()This method grants writing privileges to the calling thread and grants access to the protected list.ListstartScanning()This method grants reading privileges to the calling thread and grants access to the protected list.voidstopModifying()This method must be called when a writer thread has finished modifying the list, so that the associated readers-writer lock can be relinquished.voidstopScanning()This method must be called when a reader thread has finished accessing the list, so that the associated readers-writer lock can be relinquished.-
Methods inherited from class jade.util.RWLock
readLock, readUnlock, writeLock, writeUnlock
-
-
-
-
Method Detail
-
startModifying
public List startModifying()
This method grants writing privileges to the calling thread and grants access to the protected list.- Returns:
- The inner, protected list.
-
stopModifying
public void stopModifying()
This method must be called when a writer thread has finished modifying the list, so that the associated readers-writer lock can be relinquished.
-
startScanning
public List startScanning()
This method grants reading privileges to the calling thread and grants access to the protected list.- Returns:
- The inner, protected list.
-
stopScanning
public void stopScanning()
This method must be called when a reader thread has finished accessing the list, so that the associated readers-writer lock can be relinquished.
-
onWriteStart
protected void onWriteStart()
Description copied from class:RWLockThis placeholder method is called every time a thread actually acquires the protected resource with writing privileges (this means that, in case of multiple recursive locking by the same thread, this method is called only the first time). Subclasses can exploit this to transparently trigger a resource acquisition prolog.- Overrides:
onWriteStartin classRWLock
-
onWriteEnd
protected void onWriteEnd()
Description copied from class:RWLockThis placeholder method is called every time a thread actually releases the protected resource with writing privileges (this means that, in case of multiple recursive unlocking by the same thread, this method is called only the last time). Subclasses can exploit this to transparently trigger a resource release epilog.- Overrides:
onWriteEndin classRWLock
-
-