diff --git a/twin/index.md b/twin/index.md index 241c31f58..475437754 100644 --- a/twin/index.md +++ b/twin/index.md @@ -17,4 +17,8 @@ inheritance in java **Applicability:** Use the Twin idiom when * to simulate multiple inheritance in a language that does not support this feature. -* to avoid certain problems of multiple inheritance such as name clashes. \ No newline at end of file +* to avoid certain problems of multiple inheritance such as name clashes. + +**Credits:** + +* [Twin – A Design Pattern for Modeling Multiple Inheritance](http://www.ssw.uni-linz.ac.at/Research/Papers/Moe99/Paper.pdf) \ No newline at end of file diff --git a/twin/src/main/java/com/iluwatar/twin/App.java b/twin/src/main/java/com/iluwatar/twin/App.java index 4ecba711f..eaa21a849 100644 --- a/twin/src/main/java/com/iluwatar/twin/App.java +++ b/twin/src/main/java/com/iluwatar/twin/App.java @@ -3,20 +3,12 @@ package com.iluwatar.twin; /** * Twin pattern is a design pattern which provides a standard solution to simulate multiple * inheritance in java. - * *
- * In this example, there is a ball game, a ball needs to subclass {@link GameItem} which provide - * some common method like draw and click. Moreover, it needs to subclass {@link Thread} as ball is - * a moving item (we use {@link Thread} instead of implements {@link Runnable} for example only) - *
- * Threre is scenario, when user click the ball, the ball will stop, when user click it gain, it - * will resume to move. We create two class, ons is {@link BallItem} which subclass {@link GameItem} - * , another is {@link BallThread} which subclass {@link Thread}. These two object both hold a field - * named "Twin" reference to another object. In {@link BallItem#click()}, it will invoke - * {@link BallThread} to suspend or resume moving; in {@link BallThread#run()}, it will invoke - * {@link BallItem} for drawing. - * + * In this example, the essence of the Twin pattern is the {@link BallItem} class and + * {@link BallThread} class represent the twin objects to coordinate with each other(via the twin + * reference) like a single class inheriting from {@link GameItem} and {@link Thread}. */ + public class App { /** @@ -44,6 +36,7 @@ public class App { waiting(); + // exit ballThread.stopMe(); }