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 the difference between a static and a non-static inner class in java programming?

521


Can a lock be acquired on a class in java programming?

529


why Interface used?

529


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

579


How do you sort words in java?

529






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

560


What is the use of toarray () in java?

533


Is a char always 1 byte?

497


What is the exact difference in between unicast and multicast object? Where we will use?

553


how can you catch multiple exceptions in java?

539


Why put method is idempotent?

454


What is a get method?

525


Explain inheritance in java?

543


What is difference in between java class and bean?

560


What makes a function well defined?

507