I want to wait until my SwingWorker completes, and then I want to run another SwingWorker. In this case, Encrypteer3 is the class that extends SwingWorker.
My code is:
input = txtTekst.getText(); key = txtKey.getText(); System.out.println("thread1 start"); Encrypteer3 a = new Encrypteer3(); a.execute(); while(a.isDone()==false){ // do nothing } input = output; key = txtKey1.getText(); System.out.println("thread2 start"); Encrypteer3 b = new Encrypteer3(); b.execute(); while(b.isDone()==false){ // do nothing }
This makes my GUI freeze and uses a lot of CPU (java uses about 95% of the processor when doing this). I think the problem is that it constantly checks to see if the thread is running and what makes it so intense with the CPU.
There is no join () method in the SwingWorker class. How can I make this less intense?
source share