@Override public synchronized void run() { if (hasFinished) return; ui.matchStarted(index); GameInstance<PlayerType> gameInstance = gameFactory.getNewGameInstance(); PlayerType playerA = pA.getNewPlayerInstance(); PlayerType playerB = pB.getNewPlayerInstance(); res = gameInstance.run(playerA, playerB); pA.giveMajorPoints(res.majorPointsA); pA.giveMinorPoints(res.minorPointsA); pB.giveMajorPoints(res.majorPointsB); pB.giveMinorPoints(res.minorPointsB); if (res.majorPointsA > res.majorPointsB) { pA.matchWon(); pB.matchLost(); } else if (res.majorPointsA < res.majorPointsB) { pA.matchLost(); pB.matchWon(); } else { pA.matchDraw(); pB.matchDraw(); } hasFinished = true; ui.matchFinished(index); notifyAll(); }