HaniiPuppy

Synchronization problem

Mar 28th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public PvpGame getGamePlayerIsIn(Player player)
  2.     {
  3.         List<PvpGame> games;
  4.  
  5.  
  6.         synchronized(this.games)
  7.         { games = new ArrayList<PvpGame>(this.games); }
  8.  
  9.         for(PvpGame game : games)
  10.         {
  11.             synchronized(game.playersInLobby)
  12.             {
  13.                 if(game.playersInLobby.contains(player))
  14.                     return game;
  15.             }
  16.  
  17.             synchronized(game.playersInGame)
  18.             {
  19.                 if(game.playersInGame.contains(player))
  20.                     return game;
  21.             }
  22.  
  23.            
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment