title: LinkedList checkForComodification error java
body: <p>Ok so what I am trying to do here is to have a method &quot;running&quot; a process for a given amount of &quot;time&quot; this all seams to work to a degree but it keeps giveing these eceptions.
  This is the first execption it gives</p>
  <pre><code>     Exception in thread &quot;main&quot; java.util.ConcurrentModificationException
  </code></pre>
  <p>and then later on in the exicutio it gives this</p>
  <pre><code>    at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761)
  at java.util.LinkedList$ListItr.next(LinkedList.java:696)
  at parta.PartA.runQueueOne(PartA.java:273)
  </code></pre>
  <p>I dont know what I am doing  wrong here am i supposed make this concurrent or something? If so how? I thought that linked list were synchronous by nature? maybe that where im getting this messed up.</p>
  <p>Well any way here is the method that im usings:</p>
  <pre><code>public static void runQueueOne(LinkedList&lt;MyProcess&gt; q1, LinkedList&lt;MyProcess&gt; q2, LinkedList&lt;MyProcess&gt; q3, LinkedList&lt;MyProcess&gt; q4, int ct) {
      System.out.println(&quot;Running Level One Queue&quot;);
  
  
      for (MyProcess p : q1) {
          if (p.name.equalsIgnoreCase(q1.getFirst().name)) {
              //add 3 millsedonds to the service time
              q1.getFirst().serviceTimeTotal += 3;
              System.out.println(q1.getFirst().name + &quot; is running&quot;);
  
          } else {
              //add 3 millseconds to wait time fr the un busy one
              p.waitTimeTotal += 3;
          }
      }
  
      for (MyProcess p : q2) {
          p.waitTimeTotal += 3;
      }
      for (MyProcess p : q3) {
          p.waitTimeTotal += 3;
      }
      for (MyProcess p : q4) {
          p.waitTimeTotal += 3;
      }
  
      //calculate all the priority
      for (MyProcess p : q1) {
          p.calculatePriority();
          switch (p.priority) {
              case 1:
                  break;
              case 2:
                  q1.remove(p);
                  q2.add(p);
                  break;
              case 3:
                  q1.remove(p);
                  q3.add(p);
                  break;
              case 4:
                  q1.remove(p);
                  q4.add(p);
                  break;
          }
  
      }
      ct += 3;
  }
  </code></pre>
  <p>and here is where I call it in the main method</p>
  <pre><code>while (!allProcessDone) {
      //arrival queue
      for (MyProcess p : al) {
          addToQueue(qOne, p, currentTime);
  
          //cheack to see if all the processes are done
          if (p1.isDone == true &amp;
                  p2.isDone == true &amp;
                  p3.isDone == true &amp;
                  p4.isDone == true &amp;
                  p5.isDone == true &amp;
                  p6.isDone == true &amp;
                  p7.isDone == true &amp;
                  p8.isDone == true &amp;
                  p9.isDone == true &amp;
                  p10.isDone == true) {
              //end the loop
              allProcessDone = true;
              System.out.println(&quot;All proccess have been completed&quot;);
              break;
          }
  
  
          switch (robin) {
              case 1:
                  runQueueOne(qOne, qTwo, qThree, qFour, currentTime);
                  robin = 2;
                  break;
              case 2:
                  runQueueTwo(qOne, qTwo, qThree, qFour, currentTime);
                  robin = 3;
                  break;
              case 3:
                  runQueueThree(qOne, qTwo, qThree, qFour, currentTime);
                  robin = 4;
                  break;
              case 4:
                  runQueueFour(qOne, qTwo, qThree, qFour, currentTime);
                  robin = 1;
                  break;
  
          }
      }
  </code></pre>