When i hit a link a window popup is opened.I am having a session managed bean that loads a java.util.List.It is taking few seconds to load that list.
when i click the link twice i am getting concurrent modification exception. because the page is in session mode and first request is still loading the List, before it ends the second request tries to update the list.
I have two possible solution in hand
1) introducing synchronized block
Question : Introducing synchronized block leads to performance issue in multithread environment?
2) javascript to disable the link once it clicked.
problem : Not a good option because we need to restore the state of javascript once the popup is loaded. There is a possibility that the link is disabled forever if the popup window terminated abnormally.
Is there any other solution for this issue?
I’d choose option 1. synchronise on something in the session or on the session bean it’s self. In a single server environment this should be pretty safe but in a cluster which isn’t using sticky sessions you will have to look for a better singleton.
The performance shouldn’t be effected as you will be synchronising for each user session for that particular session bean and if there is no contention the cost isn’t worth thinking about.