mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 20:17:21 +00:00
Work on Object Pool example.
This commit is contained in:
1 parent
7f334e7024
commit
9122c7f0e6
3 files changed
+28
No files matched your search
@@ -0,0 +1,14 @@
|
|||||||
|
package com.iluwatar;
|
||||||
|
|
||||||
|
public abstract class ObjectPool<T> {
|
||||||
|
|
||||||
|
protected abstract T create();
|
||||||
|
|
||||||
|
public synchronized T checkOut() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void checkIn(T instance) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.iluwatar;
|
||||||
|
|
||||||
|
public class Oliphaunt {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.iluwatar;
|
||||||
|
|
||||||
|
public class OliphauntPool extends ObjectPool<Oliphaunt> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Oliphaunt create() {
|
||||||
|
return new Oliphaunt();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user