Как я могу каждый раз отправлять числа в определенный буфер
Suppose a router (main router) sends integer data to other 5 routers (router1, router2, router3, router4, router5) by saving the data in special buffers (5 output buffers: buffer1, buffer2, buffer3, buffer4, buffer5) located in the router itself and the other 5 routers read these data from these buffers each from its own special buffer (router1 reads from buffer1, router2 reads from buffer2, and so on). Each buffer has a limited size to 5. i.e. each buffer can save up to 5 integer numbers. Now, write a program (contains 6 threads) one thread for the main router that generates random integers and saves them in the 5 buffers randomly (it selects the buffer to save in randomly) and the other 5 threads for the 5 routers that their job is to read data from their corresponding buffers. The code has to implement the following rules: 1- The main router thread waits for 10 ms after each filling of some router of data. 2- The main router notifies all other threads that some data are written inside the buffers. 3- Other threads, after reading some data from buffers, they delete read data from the buffers. 4- The main router has to wait till a space is available in the buffers. 5- The other threads have to wait if buffers are empty (of course each thread waits for its corresponding buffer). 6- Other threads have to wait for 10 ms after each read.
Что я уже пробовал:
сделайте массив но мой доктор сказал что вы можете обойтись и без массива