Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

design for async method call

Thread view: 
Riyaz - 17 Nov 2007 15:43 GMT
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
Philipp Leitner - 17 Nov 2007 16:15 GMT
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
Daniel Pitts - 17 Nov 2007 17:57 GMT
> 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
[quoted text clipped - 3 lines]
> 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-concurr
ency-in-practice/
>

Good luck,
Daniel.
Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.