This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Processing from Callback methods

 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks.
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic