1
我有在执行的线程Java线程访问对象
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”方法后,在我的连接器类值“结果”对象的函数代码更改最少。什么是最好的方式来实现它。
以上所有类都在不同的包中。
我不知道,我怎么可以谷歌还:(