Design: Background thread with a Spring service -


i have spring service after performing tasks,initiates background async tasks. task have defined component. now, if have use method belonging service initiated thread. can autowire service in thread(component) , work. problem is...the design. brings in kind of circular dependency? how can tackle such issue?

servicea-> starts threada component->threada needs call method in servicea.

what using @async annotated method described here

a non tested example:

@service public class myservice {      private final resttemplate resttemplate;      public string mysyncmethod(){        return "hello world";     }      @async     public future<string> myasyncmethod() throws interruptedexception {         return new asyncresult<>(mysyncmethod());     }  } 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -