mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 12:58:37 +00:00
Work on Object Pool example.
This commit is contained in:
@@ -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