[Branch.java] -- class Branch implements Runnable{ //迷路の一つの分枝を扱うクラス private Rc p; //現在の先端位置 private Branch bh[]; //分岐用Branch型オブジェクトの配列 private Thread th[]; //分岐用スレッドの配列 private int useTh; //使用中の分岐用スレッド数 private int maxTh; //分岐の最大数 public Branch(Rc ip, int mx){ p = ip; if(mx > 0) maxTh = mx; else maxTh = 0; bh = new Branch[maxTh]; th = new Thread[maxTh]; useTh = 0; } public void run(){ //分枝の伸長と停止を行う boolean flag = true; do{ flag = Maze.map.grow(this, p, useTh, maxTh); //マップ上で伸長させる }while(flag); //伸長できる間ループを実行 //このスレッドが起動した全てのスレッドが終了するのを待つ for(int i=useTh; i>0; i--){ try{ th[i-1].join(); }catch(InterruptedException e){ } th[i-1] = null; bh[i-1] = null; } } public void grow(int n, int dir[]){ //分岐を含めた伸長を処理する boolean wall[] = {true, true, true, true}; for(int i=0; i