_wklArrivals.wait(); Date d = (Date) _wklArrivals.get(requestID); if (d == null) {
Date d = null; while (true) {
  public void run() {    final String fn = "PT_run(): ";      try {      log = new PrintWriter(new FileWriter("PT"+instNr+".log"), true);      log.println("Log started " + MPUtil.timestamp());      if (debug) {	dbg = new PrintWriter(new FileWriter("PT"+instNr+".dbg"), true);	dbg.println("Debug Log started " + MPUtil.timestamp());      }    } catch (IOException ioe) {      System.err.println(fn + "unable to open log files");      System.err.println(ioe);      return;    }    valStack = new Stack();    /*    String seSchema = Metaparser.getSESchema();    if (debug) dbg.println(fn+"reading in schema " + seSchema); // debug    try {      File f = new File(seSchema);      URL seURL = f.toURL();      XSDBuilder b = new XSDBuilder();      se = (XMLSchema)b.build(seURL);    } catch (Exception e) {      log.println(fn+"error while building schema");      log.println(e);      return;    }    */    Hashtable ht = new Hashtable();    SAXParser p = new SAXParser();    // p.setValidationMode(XMLParser.NONVALIDATING);    p.setContentHandler(this);    p.setErrorHandler(this);    try {      p.setFeature("http://xml.org/sax/features/validation", false);      p.setFeature("http://xml.org/sax/features/namespaces", true);      p.setFeature("http://apache.org/xml/features/validation/schema", false);    } catch (SAXNotRecognizedException snre) {      prLog(fn+"Exception setting feature:" + snre.getMessage());      return;    } catch (SAXNotSupportedException snse) {      prLog(fn+"Feature not supported:" + snse.getMessage());      return;    }     if (debug) dbg.println(fn+"creating new validator");  // debug    try {      currentVal = new Validator(xml, new PipedWriter(),      	"SEValid" + instNr, debug);      // initialize outermost depth      currentVal.setDepth(-1);      currentVal.setElement(null);      if (debug) dbg.println(fn+"starting to parse");  // debug      p.parse(new InputSource(new StringReader(xml)));      currentVal.close(true);      prDbg(fn+"checking for processor");  // debug      if (moduleName != null) {	prDbg(fn+"module "+moduleName+" should be coming");  // debug	/*	// fake!	prDbg(fn+"waiting for worklet arrival:" + MPUtil.timestamp());	Thread.currentThread().sleep(1000);	prDbg(fn+"worklet arrived:" + MPUtil.timestamp());	*/        synchronized (_wklArrivals) {	  if (_wklArrivals.containsKey(requestID)) {	    prDbg(fn+"worklet had already arrived:"+	    	(Date)_wklArrivals.get(requestID));	  } else {	    // Object lockObj = new Object();	    //_wklArrivals.put(requestID, lockObj);	    _wklArrivals.put(requestID, null);	    prDbg(fn+"waiting for worklet arrival:" + MPUtil.timestamp());	    _wklArrivals.wait();	    Date d = (Date) _wklArrivals.get(requestID);	    if (d == null) {	      _wklArrivals.wait();	    }	    prDbg(fn+"worklet arrived:" + d);	  }	}		try {	// Let Simin work his magic	  URL[] jarPath = new URL[]{new URL("file://"+moduleName)};	  URLClassLoader loader = new URLClassLoader(jarPath);	  Class cls = Class.forName	      ("psl.tagprocessor.TagProcessorImpl", true, loader);	  	  // System.out.println("Working with " + xmlDoc);	  XMLReader reader = XMLReaderFactory.createXMLReader	  ("org.apache.xerces.parsers.SAXParser");	  try {	    reader.setFeature("http://xml.org/sax/features/validation", false);	    reader.setFeature("http://xml.org/sax/features/namespaces", true);	    reader.setFeature("http://apache.org/xml/features/validation/schema", false);	  } catch (SAXNotRecognizedException snre) {	    prLog(fn+"Exception setting feature:" + snre.getMessage());	    return;	  } catch (SAXNotSupportedException snse) {	    prLog(fn+"Feature not supported:" + snse.getMessage());	    return;	  }	  TagProcessor tp = (TagProcessor) cls.newInstance();	  //tp.setJarPath("file:");	  //tp.setResource(jarPath[0].getPath());	  tp.setResource(moduleName);	  tp.init(ht);	  reader.setContentHandler(tp.getContentHandler());	  dbg.println(fn+"TagProcessor about to parse");	  reader.parse(new InputSource(new StringReader(xml)));	  dbg.println(fn+"TagProcessor about to process");	  tp.process();	} catch (Exception e) {	  log.println("Error during TagProcessor Execution:" + e);	  e.printStackTrace();	  return;	}	prDbg(fn+"Resulting Hashtable is: " + ht);	// TODO what's my number?	KXNotification edAlert = KXNotification.EDInputKXNotification(					"psl.metaparser.ParserThread", 0, ht);	slt.publish(edAlert);	     }    } catch (Exception e) {      log.println(fn+"Exception during parsing at " +       	MPUtil.printLoc(loc));      log.println(e);      e.printStackTrace();      return;    }    prDbg(fn+"shutting down wvm");    // don't shutdown if fake    wvm.shutdown();    if (debug) dbg.println(fn+"Done parsing");  }