1.4generic Subroutines and Modules
1.4generic Subroutines and Modules
1.4generic Subroutines and Modules
An event is something to which a running program (a process) needs to respond, but which occurs
outside the program, at an unpredictable time.
The most common events are inputs to a graphical user interface (GUI) system: keystrokes, mouse
motions, button clicks.
They may also be network operations or other asynchronous I/O activity: the arrival of a message,
the completion of a previously requested disk operation
A handler—a special subroutine— is invoked when a given event occurs.
Thread-Based Handlers:
In modern programming languages and run-time systems, events are often handled by a separate
thread of control, rather than by spontaneous subroutine calls
With a separate handler thread, input can again be synchronous: the handler thread makes a system
call to request the next event, and waits for it to occur.
Meanwhile, the main program continues to execute.
Many contemporary GUI systems are thread-based.
most use anonymous inner classes for handlers