what package to import when there is board?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poopsy
    New Member
    • Nov 2006
    • 50

    what package to import when there is board?

    hi all,
    i'm trying out some examples on java..and i found this code where there is board and i cant find out what package to import to make this work, im getting error where there is "board"..
    i have tried out the following but none worked:
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.applet.App let;

    plz help


    Code:
    import java.util.concurrent.CyclicBarrier;
    
    public class CellularAutomata {
    private final Board mainBoard;
    private final CyclicBarrier barrier;
    private final Worker[] workers;
    
    public CellularAutomata(Board board) {
        this.mainBoard = board;
    
        int count = Runtime.getRuntime().availableProcessors();
        
        this.barrier = new CyclicBarrier(count, new Runnable() 
        { // barrier action
            public void run(){mainBoard.commitNewValues();
            }
            }
        );
        this.workers = new Worker[count];
    
        for (int i = 0; i < count; i++)
            workers[i] = new Worker(mainBoard.getSubBoard(count, i));
        } // constructor
        
        public void start() {
            for (int i = 0; i < workers.length; i++)     
                new Thread(workers[i]).start();
            mainBoard.waitForConvergence();
    } // start()
    } // CellularAutomata
    
    
    class Worker implements Runnable {
    
        private final Board board;
    
        public Worker(Board board) { 
            this.board = board; 
            }
        
        public void run() {
            while (!board.hasConverged()) {
                for (int x = 0; x < board.getMaxX(); x++)
                    for (int y = 0; y < board.getMaxY(); y++)
                        board.setNewValue(x, y, computeValue(x, y));
                try { barrier.await(); 
                }
                catch (InterruptedException ex) { return; }
                catch (BrokenBarrierException ex) { return; }
            } // while
        } // run()
    
        private int computeValue(int x, int y) {
    // Compute the new value that goes in (x,y)
    
    }
    } // Worker
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Board is certainly not a class that comes with your JSE distribution. I suggest you'd read that example again, maybe it's one of their classes and they have shown the source of that class.

    kind regards,

    Jos

    Comment

    Working...