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

Answer Posted / dandhar

Make the "inUse" variable to static.

private static boolean inUse = false;

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is included in core java?

831


Is char * a string?

758


How many characters is 2 bytes?

751


Describe method overriding

830


What is the difference between an object-oriented programming language and object-based programming language?

784


Explain about anonymous inner classes in java?

803


What is flag in java?

755


How do you use parseint in java?

741


I want to persist data of objects for later use. What is the best approach to do so?

820


How to retrieve data from database in java using arraylist?

765


What are identifiers in java?

798


enlist some features of jdk.

757


How can we create an immutable class in java?

824


What is use of valueof () in java?

813


What is length in java?

775