Search code examples
javamultithreadingswingswingworker

running thread at the same time swing gui is running


I have this class:

public class MyClass extends Observable implements Runnable
{
...
}

I have to exceute this thread in background during swing gui running.which could be the best solution? If I don't make a mistake, I can't use SwingWorker.right?


Solution

  • SwingWorker is made specifically for that purpose. Go ahead and use it, it will work. Read its documentation first.

    If you want to use the class you already have, you can do that too. Just do this:

    new Thread (new MyClass ()).start ();.