Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8719071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:42:08+00:00 2026-06-13T06:42:08+00:00

Ok so what I am trying to do here is to have a method

  • 0

Ok so what I am trying to do here is to have a method "running" a process for a given amount of "time" this all seams to work to a degree but it keeps giveing these eceptions.
This is the first execption it gives

     Exception in thread "main" java.util.ConcurrentModificationException

and then later on in the exicutio it gives this

    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)

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.

Well any way here is the method that im usings:

public static void runQueueOne(LinkedList<MyProcess> q1, LinkedList<MyProcess> q2, LinkedList<MyProcess> q3, LinkedList<MyProcess> q4, int ct) {
    System.out.println("Running Level One Queue");


    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 + " is running");

        } 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;
}

and here is where I call it in the main method

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 &
                p2.isDone == true &
                p3.isDone == true &
                p4.isDone == true &
                p5.isDone == true &
                p6.isDone == true &
                p7.isDone == true &
                p8.isDone == true &
                p9.isDone == true &
                p10.isDone == true) {
            //end the loop
            allProcessDone = true;
            System.out.println("All proccess have been completed");
            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;

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:42:10+00:00Added an answer on June 13, 2026 at 6:42 am

    You are Concurrently accessing and modifying the Collection, that can’t be done from for-each loop directly.

    You have to use Iterator to solve this problem.

    LinkedList<MyProcess> q1 = new LinkedList<MyProcess>();
    
    Iterator<MyProcess> iterator = q1.iterator();
    
    while (iterator.hasNext()){
         MyProcess mp = iterator.next();
    
         if (mp.name.equals("xyz")){
             iterator.remove();    // You can do the modification here.
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem here im trying to upload a file first time it
Ok here I have a switch case statement which is falling through and trying
I have a bunch of divs I'm trying to organize here. The ones I'm
i'm new here and i have a question. I am trying to insert a
Here I am trying to implement the jQuery I have two main files one
Trying to have my PHP script return some SQL table queries. Here's my script
I have an interesting problem here I've been trying to solve for the last
Okay here is what I'm trying to do: I have a model object that
Here is what I am trying to do: I have a <h1> element, a
I have the following code: $data['x'] = $this->x->getResults(); $data['y'] = $data['x']; //some code here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.