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

synchronizing using exception catch #83

Open
guehochoi opened this issue Nov 2, 2013 · 1 comment
Open

synchronizing using exception catch #83

guehochoi opened this issue Nov 2, 2013 · 1 comment

Comments

@guehochoi
Copy link

we are supposed to implement the two methods to resolve concurrent modification exceotion. we can either catch the exception in the scheduler, or protect the critical section r synchronized block around the list.

however, I use synchronized block in the message receptions and catch the exception in the scheduler. This is sort of extra safe thread protection.
would it be possible grading issue resulting in deduction?

@Valakor
Copy link

Valakor commented Nov 2, 2013

Using a synchronized block is unnecessary unless you are iterating over a list of objects that may change. Simply declaring the list as Collections.SynchronizedList makes specific action calls on the list thread-safe: myList.add(something). However, if you iterate over the list in a message, you should still have a synchronized block.

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

No branches or pull requests

2 participants