Question: Write with java code and please do not answer the previous wrong answers for previous asked. 2. Multi-threaded Application: The goal in this application is

 Write with java code and please do not answer the previous

Write with java code and please do not answer the previous wrong answers for previous asked.

2. Multi-threaded Application: The goal in this application is to return the height of a spanning tree in a distributed manner. Consider a spanning tree. Each node in this tree is represented as a separate thread. Initially, each thread knows which node is its parent and which nodes are its children. The root is the thread with id 0. Thread-o initiates the following algorithm: It sends height 1 message to its children. The children that receive this message sends height 2 message to their children. The children that receives this message sends height 3 message to their children. This continues until the node (thread) receiving height message is a leaf node, since in this case the node does not have any children. When a leaf node receives the height message, it does the following: It sends height_ack message with the number that it receives previously to its parent. A parent node waits until it receives height_ack message from all its children. When this happens, it finds the maximum value received from its children from the message height_ack. Then, it sends this maximum value its parent. This process continues until the root receives the height_ack message with the actual height of the tree. Then the root prints the height of the tree. You application should also print all message passing between the threads. See an example below. 0 Height(1) Height(1) Height(1) 1 3 HEIGHT 2 Height(2) Height(2) Height(2) 4 5 6 Height(3) Height(3) 7 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!