-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmw.py
More file actions
36 lines (27 loc) · 786 Bytes
/
mw.py
File metadata and controls
36 lines (27 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from threading import Thread
import time
class Master(object):
def __init__(self):
self._max_=max;
self.worker = [];
def returnTotal(self):
return self.worker;
def work(self, id):
self.worker.append("Hello World from Thread "+str(id));
print "Thread "+str(id)+" timestamp: "+str(time.clock());
class Worker(Thread):
def __init__(self, master, id):
Thread.__init__(self);
self._master_= master;
self._id_ = id;
def run(self):
self._master_.work(self._id_);
w = Master();
workers = [];
for i in range(0,5):
workers.append(Worker(w,i));
workers[i].start();
time.sleep(.0001);
print;
print "[Printing Final Array]";
print w.returnTotal();