R で次のスクリプトを実行する場合:
library(doMC)
registerDoMC(cores=3)
# First foreach
# This runs in 3 threads
foreach(i=1:3) %dopar% sqrt(i)
# Second foreach
# This add 3 threads to the previous ones (now inactive but still consuming memory), totalling 6 threads
foreach(i=1:3) %dopar% sqrt(i)
foreach
スクリプト全体が常に 3 つのコアを使用して実行されるように、2 番目のスレッドを実行するときに最初のスレッドを再利用する方法を知りたいです。