本文主要是介绍Java,ExecutorService多线程实例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
package com.main;import java.util.concurrent.Callable;/*** Title: ProcessThread* Description:*/
public class ProcessThread implements Callable<Result> {//这个泛型要是Resultprivate String tableName;private Long fromId;private Long toId;public ProcessThread(String tableName, Long fromId, Long toId) {this.tableName = tableName;this.fromId = fromId;this.toId = toId;}@Overridepublic Result call() throws Exception {//这里的Result在实现call方法时自动添加的Thread thread = Thread.currentThread();String threadName = thread.getName();System.out.println(threadName + "," + tableName + "," + fromId + "," + toId);/*** 处理部分在这写*/return new Result(true, threadName + "," + tableName);}
}
package com.m
这篇关于Java,ExecutorService多线程实例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!