Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Thread Synchronization

 
saikat ray
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic