Currently, I always create SwingWorkerto do my actual work, and another to handle output through PipedReader.
I would like to combine these two, but I just do not see a simple way to do this, in my situation.
Given that I:
- You have a ready-made object that works (
converter, in this case) - Do you want to regularly show updates on
converterprogress in the GUI - Get an object when it
convertercompletes its task and returns.
Is there a way to do this without two SwingWorkers?
Edit: note that creating converterextend is SwingWorkernot an option.
Edit 2: in response to the comment below. This is part of a larger graphical application that processes large chunks of data (in the form of txt) and informs the user about what is wrong or what has been decided.
Code example (purely illustrative, not used):
@Override
protected Void doInBackground() {
outputWorker.useInStream(new PipedReader(outStream));
outputWorker.execute();
converter.usePipedWriter(outStream);
Output object2=converter.Convert(object1);
}
@Override
protected Void doInBackground() {
while(inStream.hasNext()) {
publish(inStream.next());
}
}
source
share