title: Lightweight way to handle concurrency for a lot of instances
body: <p>I have a class <code>HostServer</code> which contains my instances of an other kind of servers (actually Minecraft servers) and this host class may be created more than a 100 times (depending on the user). So I wanted to know, what would be a good way to handle concurrency for a considerable amount of instances (for the host class)? I have thought that I could use locks (<code>ReentrantReadWriteLock</code>), but it may be quite heavy if there is a lot of instances.</p>
  
  <p>Thank you for your answers</p>
  
  <p>EDIT (answers to the comments):</p>
  
  <p>I actually need to share the resources because there is an updater thread and the others just read the data.</p>
  
  <p>My needs are to have most recent data, so I need to handle the fact that if a thread reads and an other ones writes, the write has to come first. Although, I don't want the code to be too heavy because I may have a lot of instances (for the host class, from 10 to a 1000 and for the Minecraft server class, from 20 to 10000).</p>
  
  <p>The actual code: <a href="https://github.com/devcreart/GameStack/blob/develop/server/src/main/java/fr/creart/gamestack/server/server/HostServer.java" rel="nofollow">https://github.com/devcreart/GameStack/blob/develop/server/src/main/java/fr/creart/gamestack/server/server/HostServer.java</a></p>
  
  <p>Thanks again</p>