I am using SwingWorker to execute some heavy load tasks on an application I am making . Although today I got across the Executor class and this example :
Executors.newCachedThreadPool().execute(new Runnable() {
public void run() {
someTask();
});
Can someone explain the reasons why one would use SwingWorker instead of the above example ? This is the way I am currently using SwingWorker :
SwingWorker worker = new SwingWorker() {
protected Object doInBackground() {
someTask();
return null;
}
};
worker.execute();