Question: A team member has been having trouble with the implementation of his Singleton. Review the code below and indicate what changes are required. public class

A team member has been having trouble with the implementation of his Singleton. Review the code below and indicate what changes are required.

public class DataConnectionManager implements JSONSerialization{

private static DataConnectionManager msManager = null;

public DataConnectionManager() {

//Initialize connection

}

public static DataConnectionManager getInstance() {

if(msManager == null) {

msManager = new DataConnectionManager();

}

return msManager;

}

public static void deserialize(JSONObject obj) {

msManager = new DataConnectionManager();

msManager.setFromJSON(obj);

}

}

Step by Step Solution

3.34 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Thread Safety The current implementation is not threadsafe If multiple threads try to access getInst... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!