title: Specify the timeout of a java object
body: <p>I would like to create an object that dies when its timeout is reached. How can I achieve this ?</p>
  
  <p>For instance in pseudo code:</p>
  
  <pre><code>MyObject O = new MyObject(3000) ; // object created will be null after 3 seconds
  wait(4000) ;
  if (O == null)
    print("success") ;
  </code></pre>
  
  <p>Is it possible ?</p>
  
  <h1>Edit :</h1>
  
  <p>Actually I'm using a large map of MyObjects. Each one should die after 1 min of its creation. Now I am thinking about adding a creationDate to MyObject and a method that would check my map of MyObject when its size becomes too large... and put null to the timeout objects references. That would be another approach considering the fact I don't need all objects to be null as soon as they should (ie, they should be null after 1 min but it's not so important as long as my map isn't huge).</p>