Answer to Question #253491 in Python for shishi

Question #253491

Write a program called ReverseHello.java that creates a thread (let's call it

Thread 1). Thread 1 creates another thread (Thread 2); Thread 2 creates

Thread 3; and so on, up to Thread 50. Each thread should print "Hello from

Thread <num>!", but you should structure your program such that the

threads print their greetings in reverse order.


1
Expert's answer
2021-10-19T12:22:00-0400
class reversehello(Thread):
    def run(self):
        for j in range(49, 0, -1):
            print("Hello from Thread <"+(j+1)+">")
        try:
            Thread.sleep(1000)
        except Exception as e:
            print(e)
    @staticmethod
    def main():
        t = [None for _ in range(50)]
        for i in range(0, 49):
            t[i] = reversehello()
        for i in range(49, 0, -1):
            t[i].start()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS