title: Java Web Socket ServerEndpoint Thread Safety
body: <p>Are individual ServerEndpoints thread safe or do they belong to all clients who are interacting with them at a given time?</p>
  
  <p>Or another way to ask the same question:
  Are global objects in the ServerEndpoint class in danger of creating concurrency issues, <a href="https://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-shared-variables-and-multithreading?rq=1">like they do in HttpServlets</a>?</p>
  
  <p><a href="http://www.byteslounge.com/tutorials/java-ee-html5-websockets-with-multiple-clients-example" rel="nofollow noreferrer">This example</a> seems to indicate that each Endpoint is thread-safe, or he is just using Set and praying that concurrency issues don't pop up?</p>
  
  <p>So, assuming that the they are thread safe, does the container (Tomcat, Glassfish, etc.) create new instances of the ServerEndpoint class each time a new connection from a distinct client is established?</p>