In that case your producer thread is incorrect. You would be trying to write the data to the whole buffer every 100ms starting from the beginning each time. Store the current "first empty" and "first full" indexes to the buffer and write one item at a time. If you are using semaphores to synchronize threads, you don't need a timer, it won't work properly anyway. Simply run the producer function all the time you have new data to process. You might even use tryAcquire() so that you can return the flow elsewhere if the buffer is full.
Bookmarks