my dog learned polymorphism
The moose likes Java in General and the fly likes Processing from Callback methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Processing from Callback methods" Watch "Processing from Callback methods" New topic

Processing from Callback methods

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
I am using an API that contains callback methods. My program does some
processing, calls method in the API and awaits the callback before continuing. Can someone tell me how that typically happens. Where a program needs to wait for something before continuing.

Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128


Wont just calling a method from with in a method automatically "wait" till the called method returns (or by "catching" the variable that method returns)? or is there something between the lines when we read "call back methods"..?
Oscar Reitsma

Joined: Dec 03, 2004
Posts: 7
Hi, I'm not exactly sure of what the question is, but here goes:

Callbacks are usually used when a certain process needs to run on a seperate thread, or the process is not allowed blocking the calling thread.
The call would normally spawn a new thread, or simply place the call in an event queue of sorts. Once the processing thread is finished, it will call the original thread (callback) notifying it of completion, possibly with a result.

It is the calling threads responsibility to either wait for the response, or continue processing, depending on the situation.

Does that clarify things a little?
I agree. Here's the link:
subject: Processing from Callback methods
It's not a secret anymore!