I am not familiar with the PIM API but my guess would be that the error is occuring at:
Code:
ev = (Event)itemList.elementAt(index);
I believe this problem might occur because of one of these two reasons:
- the variable index is not correct (probably because it's not thread safe). Where do you increment or decrement the value of index and do you take care of thread concurrency?
Example:
Code:
// index initially 10
ev = (Event)itemList.elementAt(index); // no element in position 10, error is thrown
- PIMManager.this is not ensuring thread safety. The following can happen. Assume you have two threads A & B running:
Code:
// index = 0 initially
A: ev = (Event)itemList.elementAt(index); // gets element X
A: events.removeEvent(ev);
A: itemList.removeAllElements(); // all items removed
B: ev = (Event)itemList.elementAt(index); // no items in itemList, error is thrown
Hope this helps