GameServerThreadPool.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.communityserver.network;
  16. import javolution.util.FastMap;
  17. public final class GameServerThreadPool
  18. {
  19. private static GameServerThreadPool _instance;
  20. public static final GameServerThreadPool getInstance()
  21. {
  22. if (_instance == null)
  23. _instance = new GameServerThreadPool();
  24. return _instance;
  25. }
  26. private final FastMap<Integer, GameServerThread> _gameServerThreads;
  27. private GameServerThreadPool()
  28. {
  29. _gameServerThreads = new FastMap<Integer, GameServerThread>();
  30. }
  31. public final void addGameServerThread(final int serverId, final GameServerThread gst)
  32. {
  33. synchronized (_gameServerThreads)
  34. {
  35. _gameServerThreads.put(serverId, gst);
  36. }
  37. }
  38. public final GameServerThread getGameServerThread(final int serverId)
  39. {
  40. return _gameServerThreads.get(serverId);
  41. }
  42. }