I’m trying to learn how to thread a class (specifically a method in a class) and I’ve come across Thread() and SwingWorker(). This is a swing application. Which should I choose and why? Also, is there some generic way to add implementation for threading to existing methods?
Thanks
SwingWorker is mainly for executing background processes in Java Swing means UI based application , like on pressing a Button in a UI , you want some long process to happen in Background.
Thread is normally used to multitasking in Java Programs like executing two operations in a time kind of stuffs.
Thread can be implemented from Runnable interface as well as inherited from thread Class.
Check Oracle Java Docs.