0

I know how to code with Java listeners but I have one understanding ask:

Is there a loop in every listener which listen to something until the event is happening. I searched for source codes and found the implementation of some java key event listeners but naturally there are many native functions I don't understand as a beginner .

If you could explain me the principle of a listener like a simple key listener I would be very happy.

Ps: I tried to find an existing explanation but I found none explaining the principle and whether there is always a loop in the background.

Edit:  I want to know how it works. Whether with polling mechanism (loop) or by using interrupts or something 

ThX a lot

TCLKPlayer
  • 11
  • 3
  • At the end of the answer to the duplicate question, there is an example of how a listener is called. --- No, there is no loop. The code that detects/generates/produces the event will call all registered listeners. It may do so directly, or by using some framework that manages the listener registrations. – Andreas Aug 01 '18 at 00:24
  • The headline of that thread isnt my question . I know the purpose of a listener but I want to know how it works. Whether with polling mechanism (loop) or by using interrupts or something – TCLKPlayer Aug 01 '18 at 00:59
  • Right above the duplicate link it says *"This question already has an **answer** here"*. It doesn't say the *question* is a duplicate, but that writing an answer would be. The answer in the duplicate shows an example of how a listener is called, without need for polling loop or interrupts, which is what you were asking, so it *does* answer your question, even if that wasn't the explicit intent of that answer. – Andreas Aug 01 '18 at 14:52

0 Answers0