
com.jsoniter.JsonIteratorPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsoniter Show documentation
Show all versions of jsoniter Show documentation
jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
package com.jsoniter;
public class JsonIteratorPool {
private static ThreadLocal slot1 = new ThreadLocal();
private static ThreadLocal slot2 = new ThreadLocal();
public static JsonIterator borrowJsonIterator() {
JsonIterator iter = slot1.get();
if (iter != null) {
slot1.set(null);
return iter;
}
iter = slot2.get();
if (iter != null) {
slot2.set(null);
return iter;
}
iter = JsonIterator.parse(new byte[512], 0, 0);
return iter;
}
public static void returnJsonIterator(JsonIterator iter) {
iter.configCache = null;
if (slot1.get() == null) {
slot1.set(iter);
return;
}
if (slot2.get() == null) {
slot2.set(iter);
return;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy