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 field name?

774


Will set allow duplicates in java?

725


What do you mean by byte code?

740


Can we change the scope of the overridden method in the subclass?

1065


Difference between doublesummarystatistics, intsummarystatistics and longsummarystatistics ?

767


what do you mean by classloader in java?

782


What is Java Annotations?

739


what is encapsulation in java? Explain

853


What is externalizable interface?

819


Why we go for collections in java?

752


Can private class be extended java?

764


If a variable is declared as private, where may the variable be accessed?

800


Java is pass by value or pass by reference? Explain

765


What is java Applet?

819


Explain about transient variables in java?

849