Hello, I have an error that I have no idea how to fix or even what is going wrong here. I can only imagine that something is trying to be added or removed wronly from the linked list while im looping though it. Btu it does not seam like its trying to add things to the list while it running when i debug and print out actions it looks ok to me. Maybe im the switch staement is bad or something.
So this is what i have.
This is the real meat of the program that runs the processes in the linked list and calculates the service time and the wait time and moves them to a higher priority list if needed
I have this method for all for linked list so its pretty much the same for all just the last switch statement is different.
and here is where i run the methods calling them depending on robin starts out as one and the switch controlling that seams to work fine too
Matt Millar wrote:so your saying something like this?
No. You have to use the current Iterator. That's not exposed using a foreach loop, so you have to use an explicit Iterator. And if you want to add during iteration, you have to use an explicit ListIterator.
In the above, you're creating a new Iterator that's positioned before the beginning of the List and has no idea about your current iteration.
Joined: Oct 16, 2012
I Think this is how to do it but it still gives me the error.
You need to use the Iterator's remove method. Not the List's. That's the whole point of it.
During an iteration, the collection may only be structurally modified through the Iterator that's doing the iteration. That means that if you try to use the collection's methods, or if another Iterator tries to use its methods, you'll get an error. A natural consequence of this is that if we have two or more iterations going on at once, none of them can modify the collection, since that would violate the rules for all the others.
Joined: Oct 16, 2012
ok so using the new MyProcess mp will not remove it from the linked list.
now I see thanks I got a bit confused why I could not just remove it using the linked list way but now i see thanks again
here is the solution that works pretty well