Files
java-design-patterns/object-pool/src/main/java/com/iluwatar/objectpool/Oliphaunt.java
2015-05-31 11:55:18 +03:00

32 lines
477 B
Java

package com.iluwatar.objectpool;
/**
*
* Oliphaunts are expensive to create
*
*/
public class Oliphaunt {
private static int counter = 1;
private final int id;
public Oliphaunt() {
id = counter++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public int getId() {
return id;
}
@Override
public String toString() {
return String.format("Oliphaunt id=%d", id);
}
}