对象池

This commit is contained in:
石皮幼鸟 2024-04-08 23:10:34 +08:00
parent e70225cea5
commit c0b896c4fe
1 changed files with 2 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
/** /**
* 对象池防止频繁创建对象触发GC必须继承 * 对象池防止频繁创建对象触发GC
* @param <T> 对象类型 * @param <T> 对象类型
* @author spyn * @author spyn
*/ */
@ -58,6 +58,7 @@ public class ObjectPool<T> implements Iterable<T> {
if (object == null) { if (object == null) {
return; return;
} }
// 重置对象
reset.accept(object); reset.accept(object);
this.pool.push(object); this.pool.push(object);
} }