only create one instance
This commit is contained in:
parent
69158c8553
commit
d8f0ca3bdf
|
@ -13,6 +13,8 @@ public class OperatingSystem {
|
|||
private static final String ETC =
|
||||
System.getProperty("sigar.etc.dir", "/etc") + "/";
|
||||
|
||||
private static OperatingSystem instance = null;
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private String arch;
|
||||
|
@ -23,7 +25,8 @@ public class OperatingSystem {
|
|||
private OperatingSystem() {
|
||||
}
|
||||
|
||||
public static OperatingSystem getInstance() {
|
||||
public static synchronized OperatingSystem getInstance() {
|
||||
if (instance == null) {
|
||||
OperatingSystem os = new OperatingSystem();
|
||||
Properties props = System.getProperties();
|
||||
os.name = props.getProperty("os.name");
|
||||
|
@ -35,7 +38,10 @@ public class OperatingSystem {
|
|||
os.getLinuxInfo();
|
||||
}
|
||||
|
||||
return os;
|
||||
instance = os;
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
Loading…
Reference in New Issue