No, no threads (yet). Basically I have the following (really scaled down example) ...
<code>
// file 1
public class PHLog {
private FileWriter fw = null;
public PHLog(
String filename) {
// open/create file here
}
protected void finalizer() throws Throwable {
if (fw != null) {
fw.close();
}
}
}
// file Main
public class Main {
private PHLog logFile = null;
public static void main(String[] args) {
Main m = new Main();
m.logFile = new PHLog("logfile");
ClassOne c = new ClassOne(m.logFile);
}
}
// file 2, file 3, etc.
public class ClassOne {
private PHLog logFile = null;
public ClassOne(PHLog logFile) {
this.logFile = logFile;
}
}
</code>
Is there a better, more feasible, way to access the one instance of the PHLog instance created in the Main class across all the other classes (i.e., ClassOne, ClassTwo, etc.)? I originally made the instance static in PHLog and referenced statically in each class that required it, but this seemed rather cumbersome (although this other method doesn't seem much better).
Thanks,
SP