aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m5/opg2/src/PrintThread.java
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-09-17 11:29:50 +0200
committerJulian T <julian@jtle.dk>2020-09-17 11:29:50 +0200
commit5de991dd326103647b28e7d95b92b32a9e1671b9 (patch)
treea66b2976081338deae84f2cc25fde9beabbca824 /sem5/oop/m5/opg2/src/PrintThread.java
parentd285183c42f5d377b197bd0efab3bb20b240ef34 (diff)
Added m5 assignments
Diffstat (limited to 'sem5/oop/m5/opg2/src/PrintThread.java')
-rw-r--r--sem5/oop/m5/opg2/src/PrintThread.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/sem5/oop/m5/opg2/src/PrintThread.java b/sem5/oop/m5/opg2/src/PrintThread.java
new file mode 100644
index 0000000..50b8425
--- /dev/null
+++ b/sem5/oop/m5/opg2/src/PrintThread.java
@@ -0,0 +1,20 @@
+public class PrintThread extends Thread {
+ private int sleepTime;
+
+ public PrintThread(String id )
+ {
+ super(id);
+ sleepTime = (int) ( Math.random() * 5000 );
+ System.out.println( "Name: " + getName() +" Sleep: " + sleepTime );
+ }
+
+ public void run()
+ {
+ try {
+ sleep( sleepTime );
+ }
+ catch ( InterruptedException exception ) {}
+ System.out.println( "Thread " + getName() );
+ }
+
+} \ No newline at end of file