How to lock a file on different application levels?

前端 未结 6 924
萌比男神i
萌比男神i 2021-01-05 17:01

Here\'s the scenario: I have a multi threaded java web application which is running inside a servlet container. The application is deployed multiple times inside the servlet

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-05 17:41

    Would you be able to employ the use of Semaphore to control access as one at time within the application?

    To quote the API "Semaphores are often used to restrict the number of threads than can access some (physical or logical) resources"

    Whilst that API might remain container specific, the concept of a distributed Semaphore should be achievable, possibly with JGroups.

    A cursory search on Google for 'distributed java semaphore' turned up Jukebox which looks like it could address the above

提交回复
热议问题