• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Problem with Thread Synchronization

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic