0

I was asked to implement the function which waits for some action to be done. Then lets it do whatever it is supposed to do. I was asked not to use observer class. I tried with infinite loop and it worked. So i wonder if there are any other ways i could do that. (im developing an app in Jade where an supper agent communicates with other agents and once a message is received by and agent he can do some function and send back a message). I want something for that waiting part. Thanks in advance

Mike Causer
  • 8,196
  • 2
  • 43
  • 63
Vithushan
  • 503
  • 3
  • 9
  • 34
  • How about producer-consumer [http://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem] – G.S Aug 19 '14 at 09:26
  • the link you sent doesnt work. but ill do a search on the topic. Thanks for answering. – Vithushan Aug 19 '14 at 09:29
  • During paste of the link, its adding some other chars. Try searching producer-consumer problem in google. it might help you – G.S Aug 19 '14 at 09:34
  • It sounds like you need a callback method. Try looking into it http://stackoverflow.com/a/24900377/2413303 – EpicPandaForce Aug 19 '14 at 09:42
  • Is it forbidden to use the observer pattern or just the observer class? In the latter case you can create your own Observer/Listener classes/interfaces – Absurd-Mind Aug 19 '14 at 09:51

1 Answers1

1

What about using an action listener?

http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html

You can wait for the desired action and once triggered, you can implement your function.

Tarek
  • 771
  • 7
  • 18