Date: Mon, 29 Nov 2010 23:39:17 -0800 (PST) From: p4ddy <prdpsbhat@gmail.com> To: freebsd-threads@freebsd.org Subject: Creating thread dynamically in a thread pool Message-ID: <30337545.post@talk.nabble.com>
next in thread | raw e-mail | index | archive | help
Hi all, Here is the story. I m handling threads for some server. maxThreadPoolSize is given as 1000 but obviously creating 1000 threads not only takes time but also huge resources. So am thinking of creating threads dynamically for the thread pool. Initially say 100 threads will be created and based on certain factors, more number of threads will be created and added to the pool. As I m new to thread pooling, i have certain doubts: 1. how to determine initial number of threads? currently i have set it to 100 2. how to determine when to create next batch of threads? currently i m creating another batch of threads as soon as the number of active threads reaches 70% of the total threads. 3. what should be the batch size? currently i have set it to 100. so with every batch, 100 threads will be added to the pool 4. another doubt is regarding memory allocation. currently i m allocating memory to all the 1000 threads initially but threads are getting created only when there is a requirement. Is this good? or should i allocate memory dynamically too? Hope to get some answers/opinions :) Thanks in advance. -- View this message in context: http://old.nabble.com/Creating-thread-dynamically-in-a-thread-pool-tp30337545p30337545.html Sent from the freebsd-threads mailing list archive at Nabble.com.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?30337545.post>