In computer programming, the scheduler pattern is a software design pattern. It is a concurrency pattern used to explicitly control when threads may execute single-threaded code, like write operation to a file.
The scheduler pattern uses an object that explicitly sequences waiting threads. It provides a mechanism to implement a scheduling policy, but is independent of any specific scheduling policy — the policy is encapsulated in its own class and is reusable.
The read/write lock pattern is usually implemented using the scheduler pattern to ensure fairness in scheduling.
Note that the scheduler pattern adds significant overhead beyond that required to call a synchronized method.
The scheduler pattern is not quite the same as the scheduled-task pattern used for real-time systems.
Famous quotes containing the word pattern:
“In this lucid and flexible pattern only one thing remained always stationary, but this fallacy went unnoticed by Martha. The blind spot was the victim. The victim showed no signs of life before being deprived of it. If anything, the corpse which had to be moved and handled before burial seemed more active than its biological predecessor.”
—Vladimir Nabokov (18991977)