Returning null is usually the best idea if you intend to indicate that no data is available. An empty object implies data has been returned, whereas returning null clearly indicates that nothing has been…
Tag: WhoCodeFirst
What is a busy spin? Why should you use it?
Posted in Education, and WhoCodeFirst
Busy spin is one of the technique to wait for events without releasing CPU. It’s often done to avoid losing data in CPU cached which is lost if the thread…
One of the practical use of the volatile variable is to make reading double and long atomic. Both double and long are 64-bit wide and they are read in two…
Can we make array volatile in Java?
Posted in Education, and WhoCodeFirst
This is one of the tricky Java multi-threading questions you will see in the Interview. Yes, you can make an array volatile in Java but only the reference which is…
What is a compile time constant in Java? What is the risk of using it?
Posted in Education, and WhoCodeFirst
Compile time constant and Risk public static final variables are also known as a compile-time constant, the public is optional there. They are replaced with actual values at compile time…