Java – how does actionlistener work?

I have an idea of how to use action listeners and implement them, but I wonder if anyone can tell me how they listen to events?

Solution

The action listener registers events with observer pattern and notifies it of any registered events through the main event loop So no, this is not a pull mechanism, but the opposite - a push callback This is an example of "don't call us, we'll call you" Because everything in your code runs from a single thread (event loop), you don't have to worry about synchronization between different events, so your code is thread safe

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>