-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a48b51
commit a43db6a
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import time | ||
import random | ||
import threading | ||
|
||
class Hello(threading.Thread): | ||
def __init__(self, min, max): | ||
self.min, self.max = min, max | ||
threading.Thread.__init__(self) | ||
|
||
def run(self): | ||
time.sleep(self.max) | ||
|
||
for i in range(1000): | ||
print(random.choice(range(self.min, self.max))) | ||
|
||
# This creates the thread objects, but they don't do anything yet | ||
h = Hello(3,5) | ||
print(dir(h)) | ||
import sys; sys.exit(0) | ||
k = Hello(0,3) | ||
|
||
# This causes each thread to do its work | ||
print("h start") | ||
h.start() | ||
print("h finished") | ||
print("k start") | ||
k.start() | ||
print("k finished") |