Java ExecutorService: awaitTermination of all recursively created tasks

后端 未结 11 2133
太阳男子
太阳男子 2020-11-29 03:27

I use an ExecutorService to execute a task. This task can recursively create other tasks which are submitted to the same ExecutorService and those

11条回答
  •  爱一瞬间的悲伤
    2020-11-29 04:02

    If you want to use JSR166y classes - e.g. Phaser or Fork/Join - either of which might work for you, you can always download the Java 6 backport of them from: http://gee.cs.oswego.edu/dl/concurrency-interest/ and use that as a basis rather than writing a completely homebrew solution. Then when 7 comes out you can just drop the dependency on the backport and change a few package names.

    (Full disclosure: We've been using the LinkedTransferQueue in prod for a while now. No issues)

提交回复
热议问题