Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to make a method thread safe without using synchronized
keyword?

Answer Posted / jitender arora

By using a flag to determine that the method is in use by a
running thread.

Class A{

private boolean inUse = false;

public methodA(){
if(!inUse){
inUse = true;
...
...
...
inUse = false;
}
}

}

Is This Answer Correct ?    18 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What access modifiers can be used for variables?

1142


What is public static?

1025


Why do we need data serialization?

986


Can you give few examples of final classes defined in java api?

999


Can a function return a function?

1033


what is thread? : Java thread

979


Can we serialize arraylist in java?

1001


What is the difference between array list and vector in java?

933


What is the difference amongst jvm spec, jvm implementation, jvm runtime ?

961


Can a class have more than one object?

992


What is anti pattern in java?

964


What is the difference between serial and throughput garbage collector?

1094


How do you sort a set in java?

910


Why is a singleton bad?

950


How can you set an applet’s height and width as a percentage?

928