Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class XalanRecursive extends RecursiveAction implements ErrorListener {
- WorkQueue _queue;
- int _id, _tasks;
- public XalanRecursive(WorkQueue queue, int id, int tasks) {
- _queue = queue;
- _id = id;
- _tasks = tasks;
- }
- @Override
- protected void compute() {
- if(_tasks < TASKN) {
- new XalanRecursive(_queue, _id, _tasks+1).fork();
- try {
- if (verbose)
- System.out.println("Worker thread starting");
- FileOutputStream outputStream = new FileOutputStream(new File(scratch, "xalan.out." + _id));
- Result outFile = new StreamResult(outputStream);
- System.out.println(total);
- for (int i = 0; i <= total/TASKN; i++){
- String fileName = _queue.pop();
- // An empty string is the end of life signal
- if (fileName.equals(""))
- break;
- Transformer transformer = _template.newTransformer();
- transformer.setErrorListener(this);
- FileInputStream inputStream = new FileInputStream(new File(scratch, fileName));
- Source inFile = new StreamSource(inputStream);
- transformer.transform(inFile, outFile);
- inputStream.close();
- }
- } catch (TransformerConfigurationException e) {
- e.printStackTrace();
- } catch (TransformerException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- if (verbose)
- System.out.println("Worker thread exiting");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement