java - Can I run one SwingWorker within another? -


I need to run two swing workers s, only one of them should be run after the other. Could. Can I run them like this?

  class testwalker {personal firstwalker worker 1; Private Second Worker Work 2; Public TestWorker () {worker1 = new firstwalker} {@Override protected void done () {try {result1 = get ()}} hold (exception) {// exception handling} worker 2 = new seconds worker () {@Override Protected void done () {try {result2 = get ()}} hold (exception) {// exception handling}}} worker2.execute (); }} Worker1.execute (); }}  

And how can I cancel them? This way?

  cancels () (if (worker2! = Null) work2.cancel (); if (work1! = Null) work1.cancel ();}  

Thank you very much!

You can do this way and it will work, however, Unless you have other operations in your external done , which you are not showing, then you probably will be better than some things, that is, both actions in doInBackground And an array was returned to the result.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -