Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ConcurrentModificationException in CloudSim.runClockTick() #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

swghosh
Copy link

@swghosh swghosh commented Nov 20, 2024

Fixes: #187

ConcurrentModificationException can occur when SimEntity changes it's own state during run() depending upon implementation in between the Simulation clock ticks. This causes to break the simulator run similar to what happens today in CloudSimExample8. Although, this change fixes the said example it now allows users to write their SimEntity implementation in a way that during processEvent / run etc. during the lifecycle of the entity processing it can change it's own state, i.e. change the values of it's linked variables; from a design perspective of the simulator this may/may not be allowed.

In case of CloudSimExample8, the GlobalBroker implementation changes it's state during the course of it's run which today causes the exception to occur so alternative pathway is that we might need to fix the Broker implementation.

when SimEntity changes it's own state during run() / processEvent() depending upon implementation

Signed-off-by: Swarup Ghosh <[email protected]>
@swghosh
Copy link
Author

swghosh commented Nov 20, 2024

cc: @Astabol @Raove

Copy link

@Raove Raove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the error and the example runs correctly now. Code is basically the same, it just Calls the entity at location i instead of using the entity that can change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CloudSimExample8.java is not working
2 participants