Note that you could have used the 'setthreadcount' implementation for this:
setthreadcount <:{:8T.'' However, I'm not sure that creating the maximum number of threads is going to be the most efficient approach. (In some cases it might be.) Also, I'm realizing that I should have included that decrement operation in settheadcount. (It makes more sense to talk about the total number of threads than the number of worker threads.) Thanks, -- Raul On Wed, Dec 21, 2022 at 9:20 PM bill lam <bbill....@gmail.com> wrote: > > create thread pool: > MAXTHREADS_z_=: {: 8 T.'' > echo 'MAXTHREADS: ',": MAXTHREADS > 3 : 0'' > if. 1<MAXTHREADS do. > 0&T."0^:(0 < #) 0$~ (1 >. (<:9!:56'cores') <. (<:MAXTHREADS)- 1 T. '') > echo 'thread pool#0: ', ": n1=. 1 T. '' > 0&T."0^:(0 < #) 1$~ (1 >. (<:MAXTHREADS)- 1 T. '') > echo 'thread pool#1: ', ": (1 T. '') - n1 > end. > ) > > for cpu intensive tasks > f1 t.(0;<'worker';1)"0 foo > > for i/o bound tasks > g t.(1;<'worker';1)"0 bar > > > > > On Thu, Dec 22, 2022 at 9:53 AM Ak O <akin...@gmail.com> wrote: > > > Hi Bill, > > > > How is a threadpool assigned? > > For clarity, can you please show two sample commands? > > The command that creates threads in threadpool 0. > > The command that creates threads in threadpool 1. > > > > Thank you for your help. > > > > Ak > > > > > > > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm