// 随意的一个实体类
public class T {
public String userName;
public String userArg;
public String userGender;
public String userAddr;
public T(String userName, String userArg, String userGender, String userAddr) {
this.userName = userName;
this.userArg = userArg;
this.userGender = userGender;
this.userAddr = userAddr;
}
}
模拟并发 (也可以使用 JMeter)
public class Main {
public static void main(String[] args) throws InterruptedException {
ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(6, 6, 1, TimeUnit.SECONDS, new ArrayBlockingQueue<>(999999));
for (;;) {
// 每隔1毫秒提交一次任务
TimeUnit.MILLISECONDS.sleep(1);
poolExecutor.submit(Main::prcess);
}
}
// 模拟一个请求调用,最终将一个 t 对象转为 json 格式返回
public static void prcess() {
T t = new T("1", "2", "3", "4");
String res = FastJsonUtil.buildData(t);
// System.out.printf(res);
}
}
[Loaded com.alibaba.fastjson.serializer.ASMSerializer_1_T from file:/E:/maven/repository/com/alibaba/fastjson/1.2.29/fastjson-1.2.29.jar]
[Loaded com.alibaba.fastjson.serializer.ASMSerializer_1_T from file:/E:/maven/repository/com/alibaba/fastjson/1.2.29/fastjson-1.2.29.jar]
[Loaded com.alibaba.fastjson.serializer.ASMSerializer_1_T from file:/E:/maven/repository/com/alibaba/fastjson/1.2.29/fastjson-1.2.29.jar]
[Loaded com.alibaba.fastjson.serializer.ASMSerializer_1_T from file:/E:/maven/repository/com/alibaba/fastjson/1.2.29/fastjson-1.2.29.jar]
...