8 Replies Latest reply on Sep 7, 2013 10:37 AM by 8cd77b5d-5961-4262-87ba-c5ee962af6d5

    dealing with a turn based application with using a global static variable


      Hi there. I read some articles about JavaFX concurrency,so as a newbie i have to practice on it. Now i'm trying to implement a turn based application that can be played among 3-6 players. Moreover, i use a scene imported from a .fxml file and i have to update it correctly depends on some calculations of each thread (in other word players ). My main issue is, i don't wanna use a while loop which checks the state of game like;


      while( GameState != State.GAME_OVER ){


           currentPlayer = GameBoard.getNextPlayer();

           // do some actions,calculations etc.



      So, i want to use worker threads instead of this while loop. I guess using Service class for iterating and assigning the next player will be suitable instead of using the while loop and Tasks for doing each player's calculation,or waiting for some responses from Human players on UI based,however, i'm struggling with two problems.


      1. There should a global static variable ( like GameState which is an Enumarator ) determines the state of the game,so it should be updated and should be checked by each turn. Is there any way to do this ?
      2. How can i get rid off this while loop ?


      I will appreciate for every answer. Thanks anyway.