Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualTheChubu

Posted 04 October 2012 - 12:30 AM

Thanks! That one worked. Also tried with the for each but with a flag in the middle. Essentially, once it found an empty strip, it assigned to it the plane, assigned true to the flag, the for kept running but did nothing once the flag was set to true. Trows a ConcurrentModificationException in a subsequent method call that also uses a for each (the iterators are multi threaded or something?).

The one you posted is better since it stops iterating right when I want it to stop, but I also get a ConcurrentModificationException on a for each for some reason... Any ideas?

EDIT: NVM, the for each I was using was meant to land a plane on the waiting list (ArrayList) once another plane landed and its airstrip became empty. I used a for each in the airstrip to try to land every plane that was waiting, only the first one was meant to actually land (since this method is called every time an airstrip becomes empty), the others would fail.

So I removed the for each and just tried to make land the first plane of the waiting list and it worked. No more exceptions and the console output its the correct.

#2TheChubu

Posted 04 October 2012 - 12:20 AM

Thanks! That one worked. Also tried with the for each but with a flag in the middle. Essentially, once it found an empty strip, it assigned to it the plane, assigned true to the flag, the for kept running but did nothing once the flag was set to true. Trows a ConcurrentModificationException in a subsequent method call that also uses a for each (the iterators are multi threaded or something?).

The one you posted is better since it stops iterating right when I want it to stop, but I also get a ConcurrentModificationException on a for each for some reason... Any ideas?

#1TheChubu

Posted 04 October 2012 - 12:14 AM

Thanks! That one worked. Also tried with the for each but with a flag in the middle. Essentially, once it found an empty strip, it assigned to it the plane, assigned true to the flag, the for kept running but did nothing once the flag was set to true. Trows a concurrent access exception in a subsequent method call that also uses a for each (the iterators are multi threaded or something?).

The one you posted is better since it stops iterating right when I want it to stop (besides the whole "Doesn't trows an exception" thing :P).

With that for fixed and a null pointer exception fixed (din't knew that equals() returns an exception if it finds null instead of just returning false), the project works as intended. 5min fix, so close yet so far... As I said, can't code well in a 3hs timeframe.

PARTNERS