Imagine D Like Take Assignment5py Instead Distributing Work Individual Threads D Like Use Q37164544

Imagine that you’d like to take Assignment5.py, and instead ofdistributing the work to individual threads, you’d like to useindividual machines (i.e., a distributed system). Part 1 [What sortof distributed system architecture would you use for this problem,and why? Part 2 Which aspects of building the solution would besimilar to the thread solution? Which aspects would bedifferent?

#Assignment 5

import Queue
import threading
import time
import random

THREADS = 200

class addingThread (threading.Thread):
def __init__(self, l):
threading.Thread.__init__(self)
self.threadID = 3
self.name = “addingThread”
self.l = l
self.iteration = 0
def run(self):
#delay start by a random time between 0 and 0.1 sec
sleep_time= random.randint(1,1000)/10000.0
time.sleep(sleep_time)
while self.iteration < len(self.l):
#remove the comment for Question 1.3
#lock.acquire()
self.l[self.iteration] = self.l[self.iteration] +1
#remove the comment

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.