design for async method call

R

Riyaz

i've a method takes an argument and returns a value, the above
method will do some operations which is time consuming, so the caller
is blocked till the processing is finished.
Now i want to make it as asynchronous. one way of doing this is
callback mechanism.
is there any other design for this. mine is a java program.
Thanks in advance
 
P

Philipp Leitner

There are a few standard approaches to asynchrony. Callback is one of
them, Poll Objects (or Futures) are another one. In this design the
async method immediately returns a 'proxy' that will receive the
result as soon as it is available, i.e., the proxy can be 'polled' for
the result.

Ultimately, Poll Objects are only a wrappers for callbacks, but
sometimes this design is simmpler to handle and easier to understand
for the client.

/philipp
 
D

Daniel Pitts

Riyaz said:
i've a method takes an argument and returns a value, the above
method will do some operations which is time consuming, so the caller
is blocked till the processing is finished.
Now i want to make it as asynchronous. one way of doing this is
callback mechanism.
is there any other design for this. mine is a java program.
Thanks in advance
There are a few ways to handle this.
Callback is probably the best approach, however you can also use
Executor and other java.util.concurrent classes.

I suggest reading the book Java Concurrency In Practice. Its been very
useful to me in my exploration of Java concurrency.

<http://virtualinfinity.net/wordpress/technical-book-recommendations/java-concurrency-in-practice/>

Good luck,
Daniel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top