Friday, November 20, 2009

My Pirate Name a.k.a Something less serious

My pirate name is:
Dirty Jack Kidd

You're the pirate everyone else wants to throw in the ocean -- not to get rid of you, you understand; just to get rid of the smell. Even though you're not always the traditional swaggering gallant, your steadiness and planning make you a fine, reliable pirate. Arr!
Get your own pirate name from piratequiz.com.
part of the fidius.org network

Thursday, November 5, 2009

Preventing ConcurrentModificationExceptions!

I have encountered several times now, and its very annoying since the error happens randomly. After a bit of googling, I found out that using unsynchronized JAVA collections yields unpredictable results. I am hoping that synchronizing my JAVA collections manually could solve this problem. To do this, I will have to use the ready made JAVA Collections synchronize wrapper:

For example if I use the List interface like this before:

List list = new ArrayList();

I will have to wrap the ArrayList implementation using the Collections synchronize method:

List list = Collections.sychronizedList(new ArrayList);

OR

List list = new ArrayList();
list = Collections.sychronizedList(list);

I hope this works. I will refactor my code now and will update this post once I find out what happens.

EDIT: It works! You just have to synchronize the list before iterating through them :)