I have a thread with this:
private final LinkedBlockingQueue<SymbolState> symbolRefreshQueue = new LinkedBlockingQueue<>();
@Override
public void run() {
while (true) {
try {
if (SwankServer.INSTANCE.isActive()) {
while (symbolRefreshQueue.isEmpty())
Thread.sleep(1000);
List<SymbolState> refreshStates = new ArrayList<>();
symbolRefreshQueue.drainTo(refreshStates);
System.err.println("Refreshing " + refreshStates.size() + " symbols");
try {
refreshSymbols(refreshStates);
} catch (Exception e) {
// ignored
}
}
} catch (InterruptedException exception) {
}
}
}
When I run the application it does nothing at all. Once I put a breakpoint at List<SymbolState> refreshStates = new ArrayList<>(); line and then run it suddenly works just fine and I get the input:
Refreshing 27 symbols
Refreshing 1 symbols```
I am completely baffled why is that...