The scenario is the following: I use a spring controller to read and edit single file on the file system. There are many user who can edit the file and many who can read that file. I don`t want to end up writing changes to the file while other users are reading from that file. I want multiple readers at a time or a single writer at a time. To achieve that I used ReentrantReadWriteLock (It allows multiple readers or a single writer at a time.).
BUT to use my ReentrantReadWriteLock I need to spawn my own threads that are synchronized on that lock. I found out that it is not a good idea to spawn custom threads in a Webcontainers.
Is there any good approach to achieve what I need ?