Management system for concurrency management - Java thread management
Management of concurrency in communication between clients and servers in java. In the system we will have: clients, servers, a buffer and messages. The clients and servers are those previously described. As for the buffer, it is a place where clients store messages to be collected by servers; This buffer must have a certain limited capacity, and operate in a producer and consumer scheme. For their part, the messages are objects with the query made by the client, and where the server leaves the response. The operation is as follows: a client generates a message, and tries to deposit it in the buffer; if not possible, it sleeps in the buffer (passive wait). Once the message has been deposited, the client must wait for the response from the server; this time the wait is done asleep on the message object (passive wait). Each server, for its part, is continually trying to remove messages from the buffer; if not possible, please try again (active wait). However, the server must yield the processor after each attempt (yield method). Once the message is removed, it generates a response, and proceeds to awaken the client who is waiting asleep in the message.
Both the client and the server communicate with the buffer; they do not communicate directly with each other. The buffer can receive the information of how many clients there are, but not of how many messages are going to circulate. The buffer size must be configurable; It can be greater, less than or equal to the number of clients.