SingltonJAVA
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package SingletonClasses;
|
||||
|
||||
public class LogManagement {
|
||||
|
||||
// First we create an instance of the class
|
||||
private static LogManagement logM;
|
||||
|
||||
// Second, we create a PRIVATE constructor (PRIVATE TO AVOID INSTANTIATION)
|
||||
private LogManagement() {
|
||||
|
||||
}
|
||||
|
||||
// We create public method to access the one and ONLY instance
|
||||
public static LogManagement FuncLog() {
|
||||
if (logM == null) {
|
||||
synchronized (LogManagement.class) {
|
||||
if (logM == null) {
|
||||
logM = new LogManagement();
|
||||
}
|
||||
}
|
||||
}
|
||||
return logM;
|
||||
}
|
||||
|
||||
public void Logs() {
|
||||
System.out.println("Detailed logs on the way");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user