I am replacing synchorinized methods with blocks. I have one of the block like this:
As you see, the above code inside this block calls 2 methods, which are also accessed by many threads.
My doubts are :
1) Since the find() method is synchronized for any
thread, should that be included inside the sync block (the top code, written inside the block)?
2) The find method does not use db directly, but is accessed by many Threads. Hence can this be a completely synchronized method than using a blocks inside (which I feel is not possible)? If writing a block is possible, should it be around the seek() called from find() ?
3) seek() is called from a sync block above (the top code, written inside the block). Since both the caller and called are been blocked with the same instance 'db' , does synced block in seek() becomes redundant? If so, can I remove that and make it a normal method.
Please help me understand the above.
Thanks in advance,
Rajesh