Does BlockingQueue match? What actions should be taken if the Queue is empty? It looks like you probably have a limited number of connections to your third-party software. In this case, you can display an explanatory message to any user who cannot obtain the user ID. In this case, locking would not be useful. You could just implement some synchronization around the standard queue and handle the empty queues as you see fit. Something like that?
public class UserIDQueue { private static final Queue<String> USER_IDS = loadUserIDs(); private static final Object USER_ID_LOCK = new Object();
}
source share