-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoardThread.java
43 lines (39 loc) · 1.28 KB
/
BoardThread.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public class BoardThread extends Thread{
private int upperLeftX;
private int upperLeftY;
private int lowerRightX;
private int lowerRightY;
private GameOfLife game;
private int[][] nextBoard;
private int[][] currentBoard;
public BoardThread(GameOfLife game,int[][] currentBoard, int[][] nextBoard, int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY) {
this.currentBoard = currentBoard;
this.upperLeftX = upperLeftX;
this.upperLeftY = upperLeftY;
this.lowerRightX = lowerRightX;
this.lowerRightY = lowerRightY;
this.nextBoard = nextBoard;
this.game = game;
}
public void processSection() {
System.out.println("THREAD " + this.getName() + ", PROCESSING ("+upperLeftX+","+upperLeftY+")"+"TO ("+lowerRightX+","+lowerRightY+")");
for(int i = upperLeftX; i < lowerRightX; i++) {
for(int j = upperLeftY; j < lowerRightY; j++) {
int nextState = game.getNextState(i, j);
nextBoard[i][j] = nextState;
// if(nextState == 1) {
// TopLevelWindow.cells[i][j].setLive(TopLevelWindow.gridColor);
// }else {
// TopLevelWindow.cells[i][j].setDead();
// }
}
}
}
@Override
public void run() {
processSection();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}