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 are the library functions in java?

1045


How to perform merge sort in java?

1057


Difference between linkedlist and arraylist.

1070


How java enabled high performance?

1051


What is lambda programming?

1008


What is string literal in java?

1053


What is the difference between equals() and == in java?

972


How do I get a substring?

976


What is boolean example?

969


Can a constructor be protected?

1085


What is the best way to findout the time/memory consuming process?

1032


What are the rules for naming an array?

1060


What are the advantages of exception handling?

1064


we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.

2033


Why synchronization is important?

1026