title: Under what conditions should I automatically pull Connection back to Connection Pool (Java)
body: <p>I am trying to write code for a simple concurrent Connection Pool, using Java and Semaphores from <code>java.util.concurrent</code>. 
  Everything is all right but while writing the daemon thread which should check all Connections from the pool which are in use, and pull them back to the pool if they are used longer than a certain IDLE_TIMEOUT, I banged against a problem.
  How can I understand that the connection had expired? That user just forgot to close it?
  At the moment my implementation uses a <code>HashMap</code>, where I put taken <code>Connection</code> with the <code>System.currentTimeInMillis()</code>, and then my daemon thread regularly checks that time not to exceed 5 seconds. But what if user needs that Connection for the time longer than 5 sec.?
  So, I need at least an idea of better approach. Any links, materials, pieces of advice are appreciated.</p>