So far i have heard that synchronized is not recommended for ejb session bean.
I have one problem that i resolved by using synchronized.
Code where i used synchronized.
if(strBatchID != null && strBatchNumber != null){
pinGenerateSessionBeanLocalHome=getPINGenerateSessionBeanLocalHome();
if(pinGenerateSessionBeanLocalHome != null){
IPINGenerateSessionBeanLocal pinGenerateSessionBean = pinGenerateSessionBeanLocalHome.create();
synchronized(pinGenerateSessionBean){
if(pinGenerateSessionBean != null){
resultObject= pinGenerateSessionBean.generatePIN(pinBatchCustomData,iSessionInfo);
if(resultObject.getResponseCode() == PINResponseCode.SUCCESS_RESPONSE_CODE){
pinBatchCustomData= (PINBatchCustomData)resultObject.getResponseObject();
bSuccess = true;
}else{
bSuccess = false;
debugLog(PIN_MODULE_NAME,"Insertions regarding PINs could not be made successfully ");
}
}else{
bSuccess = false;
debugLog(PIN_MODULE_NAME,"PINGenerateSession Local Is Null ");
}
}
}else{
bSuccess = false;
debugLog(PIN_MODULE_NAME,"PINGenerateSession Local Home Is Null ");
}
}
Check line where i used synchronized(pinGenerateSessionBean)
to synchronized pingeneration session bean object.
It works fine. Before that i have problem when i tried to generate two batch simultaneously.
Is it create any problem ? Performance is not an issue for me.