I'm a multiprocessor newbie
I know something about streaming, but I need to increase the speed of this computation, hopefully with multiprocessing:
Example Description: sends a string to a stream, modifies a string test + send the result back for printing. A.
from threading import Thread
class Alter(Thread):
def __init__(self, word):
Thread.__init__(self)
self.word = word
self.word2 = ''
def run(self):
for i in range(80000):
self.word2 = self.word2 + self.word
thread1 = Alter('foo')
thread2 = Alter('bar')
thread1.start()
thread2.start()
while thread1.is_alive() == True: pass
while thread2.is_alive() == True: pass
print(thread1.word2)
print(thread2.word2)
6 , , .
-, . , , , - , , , . (8 ) multiprocessing.cpu_count(), , . - , , . Python 3