sometimes when using @async without return type of future returns null returns string. in documentation mentioned return type of future must. confused why happening?
e.g.this 1 working
@service public class myclass implements myclass2{ @async @override public string getstring() { return "hello"; } }
please don't return string @async method. against intentions of makers. excerpt spring execution & scheduling docu:
even methods return value can invoked asynchronously. however, such methods required have future typed return value. still provides benefit of asynchronous execution caller can perform other tasks prior calling get() on future.
if asynchronous method has return type, must future object!
why? because otherwise method invoker won't able wait completion of thread has handled @async method. waiting thread-completion handled future.get
Comments
Post a Comment