Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. class XalanRecursive extends RecursiveAction implements ErrorListener {
  2.  
  3.         WorkQueue _queue;
  4.         int _id, _tasks;
  5.  
  6.         public XalanRecursive(WorkQueue queue, int id, int tasks) {
  7.             _queue = queue;
  8.             _id = id;
  9.             _tasks = tasks;
  10.         }
  11.        
  12.         @Override
  13.         protected void compute() {
  14.            
  15.             if(_tasks < TASKN) {
  16.                 new XalanRecursive(_queue, _id, _tasks+1).fork();
  17.                 try {
  18.                     if (verbose)
  19.                         System.out.println("Worker thread starting");
  20.                     FileOutputStream outputStream = new FileOutputStream(new File(scratch, "xalan.out." + _id));
  21.                     Result outFile = new StreamResult(outputStream);
  22.                     System.out.println(total);
  23.                     for (int i = 0; i <= total/TASKN; i++){
  24.                         String fileName = _queue.pop();
  25.                         // An empty string is the end of life signal
  26.                         if (fileName.equals(""))
  27.                             break;
  28.                         Transformer transformer = _template.newTransformer();
  29.                         transformer.setErrorListener(this);
  30.                         FileInputStream inputStream = new FileInputStream(new File(scratch, fileName));
  31.                        
  32.                         Source inFile = new StreamSource(inputStream);
  33.                         transformer.transform(inFile, outFile);
  34.                         inputStream.close();
  35.                     }          
  36.                
  37.                 } catch (TransformerConfigurationException e) {
  38.                     e.printStackTrace();
  39.                 } catch (TransformerException e) {
  40.                     e.printStackTrace();
  41.                 } catch (IOException e) {
  42.                     e.printStackTrace();
  43.                 }
  44.                 if (verbose)
  45.                     System.out.println("Worker thread exiting");
  46.                 }
  47.         }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement