How can I implement a parallel class as described below
<p>The code below does what is required for between 10 and 20 generations.</p>

<p>The 'switch' represents a context free finite state automaton for an L-system problem from "The Algorithmic Beauty of Plants", page 5 and is not a homework. I intend to model this using a MicroBlaze processor on a Xilinx Spartan3 FPGA but I am developing the simulation in software initially to identify as many issues as possible.  </p>

<p>However I now wish to modify the program so that the 'switch' part can be used to provide a parallel operation rather than sequentially as now.  </p>

<p>I do know I can replace the switch with a block of if .. else's.</p>

<p>Hence what I wan't to do is to enclose the switch into a class with a character input and character output similar to now. Then make an ArrayList of switch objects such that each new object has an index that matches the correct cellType index, so for each generation all of the cells are updated in parallel rather than sequentially. It may be that a collection might be the way forward.</p>

<p>Any pointers will be helpful.</p>

<p>Stewart.</p>

<pre><code>import javax.swing.*;
import java.awt.event.*;
import java.util.*;

public abstract class D0Lsimple1 extends JFrame implements ActionListener {

  //private static Object celltype;

  public static void d0lSimple1() {
  // Open a window to get the time cycle length and convert from a string
  // to an integer.
  String tc = JOptionPane
            .showInputDialog("Enter number of generation cycles, must be between 10 and 20.");
  int tcycle = Integer.parseInt(tc);

 // create an ArrayList with seed cell A.
List&lt;Character&gt; cellType = new ArrayList&lt;Character&gt;();
cellType.add('A');
System.out.println("cellType: " + cellType);
List&lt;Character&gt; newType = new ArrayList&lt;Character&gt;();

while (tcycle &gt; 0) {

    int procid = (cellType.size() - cellType.size());

    while (procid != cellType.size()) {
        char type = cellType.get(procid).charValue();

        switch (type) {
        case 'A':
            newType.add('C');
            newType.add('B');
            break;
        case 'B':
            newType.add('A');
            break;
        case 'C':
            newType.add('D');
            newType.add('A');
            break;
        case 'D':
            newType.add('C');
            break;
        default:
            System.out.println("Invalid cell type." + type);
            break;
            }
    procid++;
    }
    List&lt;Character&gt; temp = new ArrayList&lt;Character&gt;(cellType);
    cellType.clear();
    cellType.addAll(newType);
    newType.clear();
    // newType.addAll(temp);

    System.out.println("procid: " + procid);
    System.out.println("cellType: " + cellType);
    /*
     * When using this program do not input a number for growth cycles
     * greater than 37, as my computer ran out of resources.
     * For inputs greater than 8 one of the println line should be // out
     * dependent on which is more important.
     * 
     */
    tcycle--;
    }
      }

    public static void main(String[] args) {
   // Schedule a job for the event-dispatching thread:
   // creating and showing this application's GUI.
   javax.swing.SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
        d0lSimple1();
        }
      }
   );
}
}
</code></pre>
