I think the answer is critically dependent on the type of data managed by the Foo subclasses. If the results are uniform, just SwingWorker and create specific subclasses accordingly:
class Whatever {} abstract class AbstractFoo extends SwingWorker<List<Whatever>, Whatever> {} class Foo1 extends AbstractFoo { @Override protected List<Whatever> doInBackground() throws Exception { ... } }
If each one controls a different type, create a parent family tree and create each specific subclass with the required type:
class Whatever {} class Whichever {} abstract class GenericAbstractFoo<T, V> extends SwingWorker<T, V> {} class Foo2 extends GenericAbstractFoo<List<Whatever>, Whatever> { @Override protected List<Whatever> doInBackground() throws Exception { ... } } class Foo3 extends GenericAbstractFoo<List<Whichever>, Whichever> { @Override protected List<Whichever> doInBackground() throws Exception { ... } }
source share