Anurag Agarwal 33ea7335b1 Java 11 migration: patterns (remaining b-c) (#1081)
* Moves business-delegate pattern  to java 11

* Moves bytecode pattern  to java 11

* Moves caching pattern  to java 11

* Moves callback pattern  to java 11

* Moves chain pattern  to java 11

* Moves circuit-breaker pattern  to java 11

* Moves collection-pipeline pattern  to java 11

* Moves command pattern  to java 11

* Moves commander pattern  to java 11

* Moves composite pattern  to java 11

* Corrects test cases
2019-11-12 21:56:46 +02:00
..
2017-11-28 20:55:52 +02:00
2019-10-12 20:05:54 +03:00
2017-11-28 21:28:53 +02:00

layout, title, folder, permalink, categories, tags
layout title folder permalink categories tags
pattern Callback callback /patterns/callback/ Other
Java
Difficulty-Beginner
Functional
Idiom

Intent

Callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time.

alt text

Applicability

Use the Callback pattern when

  • when some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.

Real world examples

  • CyclicBarrier constructor can accept callback that will be triggered every time when barrier is tripped.