呼び出しメソッドから将来のオブジェクトへの文字列型の反復セット値を返すにはどうすればよいですか。反復値を配列に格納してその配列を返す必要がありますか、それとも誰かが私を助けてくれますか?
7098 次
2 に答える
3
を使用しCallable<List<String>>
て、エグゼキュータに送信します。エグゼキュータは、メソッドがを返すaを返しFuture
ます。get()
List<String>
ExecutorService executorService = Executors.newSingleThreadExecutor();
Callable<List<String>> task = new Callable<List<String>>() {
public List<String> call() throws Exception {
List<String> list = new ArrayList<String>();
// populate list
return list;
}
};
Future<List<String>> future = executorService.submit(task);
// the list from above, returns once execution is complete
List<String> list = future.get();
于 2012-11-07T12:40:35.553 に答える
0
Objectを返すsubmit()
メソッドを使用します。ExecutorService
Future
于 2012-11-07T12:20:27.893 に答える