end of a thread's execution throws java.lang.NullPointerException
Posted on 2006-11-18
I made an application, call it a.java, that creates 2 thread objects, call them t1 and t2. t1 and t2 each use a parser object to parse an xml file. a.java creates the two parser objects, call them p1 and p2, and passes them to t1, and t2, respectively. There is no "communication" between the parser objects and a.java object.
When one of the threads finishes, the other thread dies. The error I get is
Exception in thread "Thread-2" java.lang.NullPointerException
where iroom is the package, xmlp is the parser class from which p1 and p2 are instantiated, and ParserRunner is the class from which t1 and t2 are instatiated, and it implements Runnable interface.
When I only create one thread the program finishes without any errors.
I am new to threads in Java, and would appreciate any help in solving this problem.