Fixing multi-threaded issues.

This commit is contained in:
marcins78@gmail.com
2012-07-30 20:19:13 +00:00
parent e99aabd052
commit 46d90b9785

View File

@@ -131,24 +131,14 @@ public class LotroServer extends AbstractServer {
new GameResultListener() {
@Override
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons) {
_lock.writeLock().lock();
try {
final Map.Entry<String, String> loserEntry = loserPlayerIdsWithReasons.entrySet().iterator().next();
final Map.Entry<String, String> loserEntry = loserPlayerIdsWithReasons.entrySet().iterator().next();
gameRecordingInProgress.finishRecording(winnerPlayerId, winReason, loserEntry.getKey(), loserEntry.getValue());
} finally {
_lock.writeLock().unlock();
}
gameRecordingInProgress.finishRecording(winnerPlayerId, winReason, loserEntry.getKey(), loserEntry.getValue());
}
@Override
public void gameCancelled() {
_lock.writeLock().lock();
try {
gameRecordingInProgress.finishRecording(participants[0].getPlayerId(), "Game cancelled due to error", participants[1].getPlayerId(), "Game cancelled due to error");
} finally {
_lock.writeLock().unlock();
}
gameRecordingInProgress.finishRecording(participants[0].getPlayerId(), "Game cancelled due to error", participants[1].getPlayerId(), "Game cancelled due to error");
}
}
);