title: Thread Confinement
body: <p>I am reading Java Concurrency in Practice and kind of confused with the thread confinement concept. The book says that</p>
  
  <blockquote>
    <p>When an object is confined to a thread, such usage is automatically thread-safe even if the confined object itself is not</p>
  </blockquote>
  
  <p>So when an object is confined to a thread, no other thread can have access to it? Is that what it means to be confined to a thread? How does one keep an object confined to a thread?</p>
  
  <p><strong>Edit:</strong>
  But what if I still want to share the object with another thread? Let's say that after thread A finishes with object O, thread B wants to access O. In this case, can O still be confined to B after A is done with it?</p>
  
  <p>Using a local variable is one example for sure but that just means you don't share your object with other thread (AT ALL). In case of JDBC Connection pool, doesn't it pass one connection from one thread to another once a thread is done with that connection (totally clueless about this because I never used JDBC).</p>