Files
java-design-patterns/object-pool/src/main/java/com/iluwatar/objectpool/Oliphaunt.java

32 lines
477 B
Java
Raw Normal View History

package com.iluwatar.objectpool;
2015-05-24 14:13:07 +03:00
2015-05-24 22:19:52 +03:00
/**
*
* Oliphaunts are expensive to create
*
*/
2015-05-24 14:13:07 +03:00
public class Oliphaunt {
2015-05-24 21:47:57 +03:00
private static int counter = 1;
private final int id;
public Oliphaunt() {
id = counter++;
2015-05-24 22:19:52 +03:00
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
2015-05-24 21:47:57 +03:00
}
public int getId() {
return id;
}
@Override
public String toString() {
return String.format("Oliphaunt id=%d", id);
}
2015-05-24 14:13:07 +03:00
}