0

I have a function, which sends a message to a Server, and another function which would be called if the answer arrives. So I want to return the parameter of the recive function in the request function. How can I do this ?

private Answer request(User user){
 //perform request
 //wait for answer but how
}

public void recive(Answer answer){
  //I want the answer parameter
}
shim_
  • 357
  • 5
  • 14

1 Answers1

0

You dont simply wait. You create your custom listener : look here Create a custom event in Java You need to call this event with the parameters YOU specify

Community
  • 1
  • 1
ntakouris
  • 898
  • 1
  • 9
  • 22
  • Just a quick note,Zarkopafilis solution refers to a programming methodology named [Event-Driven Programming](http://en.wikipedia.org/wiki/Event-driven_programming). – georgez Sep 25 '13 at 19:16