2015-05-31 11:55:18 +03:00
|
|
|
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
|
|
|
}
|