diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java new file mode 100644 index 0000000..73189fd --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java @@ -0,0 +1,39 @@ +/* Listing2204.java */
+
+class A2204
+{
+ int irgendwas;
+ //...
+}
+
+class B2204
+extends A2204
+implements Runnable
+{
+ public void run()
+ {
+ int i = 0;
+ while (true) {
+ if (Thread.interrupted()) {
+ break;
+ }
+ System.out.println(i++);
+ }
+ }
+}
+
+public class Listing2204
+{
+ public static void main(String[] args)
+ {
+ B2204 b = new B2204();
+ Thread t = new Thread(b);
+ t.start();
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e){
+ //nichts
+ }
+ t.interrupt();
+ }
+}
\ No newline at end of file |
