Piping data between threads with Java

后端 未结 2 440
梦谈多话
梦谈多话 2021-02-09 08:01

I am writing a multi-threaded application that mimics a movie theater. Each person involved is its own thread and concurrency must be done completely by semaphores. The only i

2条回答
  •  自闭症患者
    2021-02-09 08:44

    Think it in terms of shared memory with read/write lock.

    1. Create a buffer to put the message.
    2. The access to the buffer should be controlled by using a lock/semaphore.
    3. Use this buffer for inter thread communication purpose.

    Regards

    PKV

提交回复
热议问题