If multiple threads are accessing a queue, but it is currently being changed by only one getNextInQueue() method, what is the most suitable form of queue access synchronization?
Currently, I have declared the queue as ConcurrentLinkedQueue , but I do not want to go to a dead end where several threads are waiting for the lock to exit. Another way I can handle this is not by queue synchronization, but by getNextInQueue() synchronization. However, since this code will be used in the future, I donβt think it will scale. (Every programmer who makes changes to the queue will need to make sure that it synchronizes the operation.)
Thoughts?
source share