lundi 23 septembre 2019

java- how to multiple(indefinite) asynchronous callbacks. is there a desing pattern or somehing?

I am not sure if I asked right in title but here is the problem. I have a class that does a jop asyncronously and also has to run on Swing UI thread. like this


SwingUtilities.invokeLater(() -> {
  myobj.dosomething(()->{

   SwingUtilities.invokeLater(() -> {
     myobj.dosomething(()->{
       //here it needs to repeat this again and again. 
       //for an indefinte number of times. So it is hedious to reapat this code
       //for few times  and impossible to make it dynamic based on user input. 

     });
    });
   });
});

Aucun commentaire:

Enregistrer un commentaire