From 9312059f191f3124cda755cb8959e7344ea7ecc8 Mon Sep 17 00:00:00 2001 From: vehpsr Date: Fri, 27 Mar 2015 11:13:29 +0200 Subject: [PATCH 1/2] Callback pattern description amendment --- callback/src/main/java/com/iluwatar/App.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callback/src/main/java/com/iluwatar/App.java b/callback/src/main/java/com/iluwatar/App.java index 6a36d66d7..2d79d8edf 100644 --- a/callback/src/main/java/com/iluwatar/App.java +++ b/callback/src/main/java/com/iluwatar/App.java @@ -1,7 +1,7 @@ package com.iluwatar; /** - * Callback pattern is more native for dynamic languages where function are first-class citizen. + * Callback pattern is more native for functional languages where function is treated as first-class citizen. * Prior to Java8 can be simulated using simple (alike command) interfaces. */ public class App { From 15adc6751ecdbad1b26d3620a153d3a943f59fdd Mon Sep 17 00:00:00 2001 From: vehpsr Date: Fri, 27 Mar 2015 17:38:10 +0200 Subject: [PATCH 2/2] Callback pattern: added real world example --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 24735a590..4a7991277 100644 --- a/README.md +++ b/README.md @@ -421,6 +421,8 @@ Behavioral patterns are concerned with algorithms and the assignment of responsi **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] (http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CyclicBarrier.html#CyclicBarrier%28int,%20java.lang.Runnable%29) constructor can accept callback that will be triggered every time when barrier is tripped. # Frequently asked questions