From ec73d2ea1e5b2d90a2193e029a8af11cd951914d Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Thu, 12 Jan 2017 21:05:23 +0900 Subject: [PATCH] Parallel: wait for all ths to die Former-commit-id: d95a5fc60c424cb1722d70ced610a81237ddb681 Former-commit-id: 64d1177a164a2a53e9beabe634a6f5997cfa8d7b --- src/net/torvald/terrarum/concurrent/ThreadParallel.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/net/torvald/terrarum/concurrent/ThreadParallel.kt b/src/net/torvald/terrarum/concurrent/ThreadParallel.kt index 3166b0ce4..31fa1b439 100644 --- a/src/net/torvald/terrarum/concurrent/ThreadParallel.kt +++ b/src/net/torvald/terrarum/concurrent/ThreadParallel.kt @@ -25,6 +25,14 @@ object ThreadParallel { pool.forEach { it?.start() } } + /** + * Start all thread in the pool and wait for them to all die. If the thread in the pool is NULL, it will simply ignored. + */ + fun startAllWaitForDie() { + pool.forEach { it?.start() } + pool.forEach { it?.join() } + } + /** * Primitive locking */