import java.util.Date;

public class TimeStampedObj {
    Object payload;
    Date timeStamp;

    public TimeStampedObj(Object o) {
	this.payload = o;
	TimeStampedObjCache.lastObjCreated = this;
	this.timeStamp = new Date();
    }

    public Date getTimeStamp() { return timeStamp; }
	
    public Object getPayload() { return payload; }

    // Driver: what will errorCount be when printed?
    public static void main(String[] args) {
	int errorCount = 0;
	int iterations = 10000;
	Thread t;
	
	for (int i=0; i<iterations; i++) {
	    t = new Thread(new Runnable() {
		    public void run() { new TimeStampedObj(new Object()); }
		});
	    t.start();
	    if (TimeStampedObjCache.lastObjCreated.getTimeStamp() == null) {
		errorCount++;
	    }
	}
	System.out.println(errorCount);
    }
}
