Question
1. Client-Server Application: Write a client and multi-threaded server application in Java that does the following: Client sends 9 positive numbers as a whole to
1. Client-Server Application: Write a client and multi-threaded server application in Java that does the following: Client sends 9 positive numbers as a whole to the server so that the server can return the sum of them. When server receives the numbers, it splits the number into 3 equal chunks to be distributed to 3 threads. When each thread receives its own chunk of numbers, it computes their sum and writes it to a shared location. When all threads complete performing their tasks, the server sends the resulting sum to the client. See an example below.
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-0 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.
need this code in java u can count as 2 questions but please dont delete it
Client: Server: Sends the following numbers to server: 1, 5, 9, 10, 20, 25, 90, 10, 100 Client receives the sum 270 Receives the numbers from client Server creates 3 threads and Sends 1, 5, 9 to Thread-o Sends 10, 20, 25 to Thread-1 Sends 90, 10, 100 to Thread-2 Thread-o performs its task and writes the sum 15. Thread-1 performs its task and writes the sum 55. Thread-2 performs its task and writes the sum 200. Server sends 270 to client 0 Height(1) Height(1) Height(1) 1 3 HEIGHT 2 Height(2) Height(2) Height(2) 5 Height(3) Height(3) 7 8Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started