File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem with Thread Synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem with Thread Synchronization" Watch "Problem with Thread Synchronization" New topic
Author

Problem with Thread Synchronization

saikat ray
Greenhorn

Joined: Dec 27, 2011
Posts: 4
Hi,

Following is the pseudo logic of a method inside a web service BLO which in turn calls another web service.


Public void xxx() {

int numberOfFailure=getFromApplicationContext();

//call a web service

if(the call is successfull){

//business logic

numberOfFailure=0;

}
else{

numberOfFailure++;

}

//some other business logic

setinApplicationcontext(numberOfFailure);


if(isSrviceCallSuccessfullflag){

if(numberOfFailure==3){

sendMail();

}


}

}




This is the pseudo code of the method. The method calls a web service.On 3 consecutive failures it sends a mail .

Can you tell me is there a way to solve the synchronization problem without making the method synchronized? I did not find block synchronization option to be available here as the service call then gets included in the block as well (or may be i am wrong).
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Hi, and welcome to the Ranch!

1. When posting code (even pseudocode), please UseCodeTags so it will be readable.

2. What, exactly, is "the synchronization problem" you're trying to solve?

3. Whether the service call gets included in the sync block depends entirely on whether or not you put it there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Thread Synchronization