mercredi 30 novembre 2016

Is the class a singleton?

Is the class listed below a singleton? Since the constructor is declared as public, can I infer that the class is a singleton with wrong implementation?

public class CreateDevice extends Functionality{

  private static Simulator simulator;
  ConnectionDB connect = ConnectionDB.getInstance();


  public CreateDevice(Simulator simulator){
    this.simulator = simulator;
  }

  private static CreateDevice instance;
  synchronized public static CreateDevice getInstance() {
    if(instance == null){
      instance = new CreateDevice(simulator);
    }       
      return instance;
  }
}

Aucun commentaire:

Enregistrer un commentaire