Hi Vishesh,
Sorry I missed this.
Yes, well, there are some methods in ConcurrentRadixTree:
Those methods would allow you to extend the scope of the locks used by the tree itself, to encapsulate any other write operations you want to perform as well (for example, on the sets you mentioned).
Basically if you make a subclass of ConcurrentRadixTree, you can add your own custom method to it to leverage this as follows:
public void myCustomMethod() {
acquireWriteLock();
try {
// you can call any other method(s) in the tree or perform other operations here, and no other threads will be able to modify the tree until you have finished.
}
finally {
releaseWriteLock();
}
}
While your method is executing, other _writing_ threads which try to modify the tree concurrently will be blocked. However reading threads will not be blocked by default. So this should work fine wrt reading threads as long as the implementation of the sets you will store as values in the tree will be thread-safe.
OTOH if the implementation of the sets you will store as values in the tree will NOT be thread-safe, there is another option where you can supply restrictConcurrency = true to the constructor of the ConcurrentRadixTree. This enables a mode where reading threads will be blocked as well while your method is executing. In that mode you sacrifice some concurrency.
Hope that helps,
Niall