/** * This method runs in the background * * <p>It waits for new command to be pushed into it, * * <p>and then pop the commands by their version number * * <p>in order to execute them */ @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public void run() { Command modelCommand = null; while (active) { try { modelCommand = commandQueue.popCommand(); if (modelCommand != null) { doJobs(modelCommand); } } catch (Exception e) { if (active) { log.fatal("An exception occur in the core thread : Expected lost of data ", e); modelCommand.push(COMMAND_STATUS, INTEGER, CommandStatus.unExpectedException.getId()); synchronized (modelCommand) { modelCommand.notify(); } } } } }