01-22-2008, 11:20 PM
I saw a piece of codes like this in a Java class:
1)Where could the Thread object be first created? I did a full application search (source codes) and did not find it. In another way, how could the Thread be directly used without first being instantiated?
2)Where does it (getContextClassLoader().getResourceAsStream) try to get the filename?
01-23-2008, 04:45 AM
Answers to your questions:
1) Every application is inherently single threaded. Every time an application is kicked off it is running in it's own thread so the static call to Thread.currentThread() (assuming it's a single threaded application) will return your applications main thread. Beyond that, you can create separate threads within your program by creating your own instances of a Thread.
2) Whatever the value of "filename" is, that's where the application is trying to load the file from. It should be defined within the code you're looking at, or passed in as a command line argument.
01-23-2008, 07:36 PM
Thanks for the response.
The filename ="test.properties". But this file is located in the directory of C:\ibm\project_jars.
I mean how could the system know this file (test.properties) is in the directoryof C:\ibm\project_jars ? Or where could the C:\ibm\project_jars be specified (I am using IBM's RAD 7)?
01-23-2008, 10:35 PM
If the filename doesn't use an absolute path, it will look in the directory from which the application was launched. I believe this is stored in the system property "user.dir" but I could be wrong.
If your application was launched from C:\ibm\project_jars then it should find the file. If not, then you'll have to do a little more digging.