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 is the difference between private & public & friendly classes?

1015


What is meant by object oriented programming – oop?

922


What is difference between arraylist and list in java?

1022


How we can declare a static variable?

1064


What is the effect of keeping a constructor private?

872


What is hashing principle in java?

969


How do you add an arraylist to an array in java?

930


How to restrict a member of a class from inheriting by its sub classes?

1284


What is the difference between class forname and new?

944


What is ph and buffers?

937


Which number is denoted by leading zero in java?

1192


How many threads can java run?

1052


What does indexof mean?

943


Explain about the interpreter in java?

992


What is volatile keyword in java

1070