eBay Interview Question

How would we make Singleton thread protected except interviewer did not want to include Synchronized block in there.

Interview Answers

Anonymous

Apr 9, 2016

By making the costructor static

1

Anonymous

Jul 11, 2016

public class ThreadSafeSingleton { private static final Object instance = new Object(); protected ThreadSafeSingleton() { } // Runtime initialization // By defualt ThreadSafe public static Object getInstance() { return instance; } }

Anonymous

Mar 31, 2015

Hi, It will be great for us if you write more Technical and coding questions. Thank you