The Definitive Guide to Modern Java Clients with JavaFX by Stephen Chin & Johan Vos & James Weaver

The Definitive Guide to Modern Java Clients with JavaFX by Stephen Chin & Johan Vos & James Weaver

Author:Stephen Chin & Johan Vos & James Weaver
Language: eng
Format: epub
ISBN: 9781484249260
Publisher: Apress


public class GameOfLifePublisherConsumer extends GraphicApp {

final int WIDTH = 2500;

final int HEIGHT = 2500;

final int CELL_SIZE = 2;

boolean currentGeneration[][];

int columns = WIDTH / CELL_SIZE;

int rows = HEIGHT / CELL_SIZE;

// this is the desired number of frames

int numberOfFramesPerSecond = 0;

private GameOfLife gameOfLife;

ConcurrentLinkedQueue<boolean[][]> cellsQueue;

public static void main(String[] args) {

launch();

}

@Override

public void setup() {

cellsQueue = new ConcurrentLinkedQueue<>();

width = WIDTH;

height = HEIGHT;

gameOfLife = new GameOfLife(columns, rows, CELL_SIZE);

currentGeneration = gameOfLife.newCells();

Task<Void> producerTask = new Task<Void>() {

@Override

protected Void call() throws Exception {

while(true) {

cellsQueue.add(currentGeneration);

currentGeneration = gameOfLife.newGeneration(currentGeneration);

}

}

};



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.