summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java')
-rw-r--r--Master/Reference Architectures and Patterns/hjp5/examples/Listing2204.java39
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