mirror of
https://github.com/PacktPublishing/Hands-On-GPU-Programming-with-CUDA-C-and-Python-3.x-Second-Edition.git
synced 2025-07-21 12:51:06 +02:00
21 lines
546 B
Python
21 lines
546 B
Python
import threading
|
|
|
|
class PointlessExampleThread(threading.Thread):
|
|
def __init__(self):
|
|
threading.Thread.__init__(self)
|
|
self.return_value = None
|
|
|
|
def run(self):
|
|
print('Hello from the thread you just spawned!')
|
|
self.return_value = 123
|
|
|
|
def join(self):
|
|
threading.Thread.join(self)
|
|
return self.return_value
|
|
|
|
|
|
NewThread = PointlessExampleThread()
|
|
NewThread.start()
|
|
thread_output = NewThread.join()
|
|
print('The thread completed and returned this value: %s' % thread_output)
|