我有一个执行线程的函数
Public Class Connector{
private static void anyFileConnector() {
// Starting searching Thread
traverse.executeTraversing();
}
}
public class Traverse {
private synchronized void executeTraversing(Path dir) {
ExecutorService executor = Executors.newFixedThreadPool(1);
// Doing some operation
executor.submit(newSearch);
}
}
} catch (IOException | DirectoryIteratorException x) {
// IOException can never be thrown by the iteration.
} finally {
executor.shutdown();
}
}
}
public class Search implements Runnable {
private List<ResultBean> result = new ArrayList<ResultBean>();
public void run() {
synchronized (Search.class) {
// In this Search Method i am setting above list "result"
this.search();
}
}
我希望在“executeTraversing”方法之后,在我的连接器类中具有值的“结果”对象,代码更改最少。到达那里的最佳方法是什么。
以上所有类都在不同的包中。
我不知道,我怎么也可以用谷歌搜索:(