There is a pattern that i don't remember the name for this kind of tasks. You should create a pool of n threads and assign work to them from a main thread. You can use two queue per thread.
On "in" queue you will insert a task, and on "out" queue you will read the task's result. Threads are blocked waiting the "in" queue to have something to read... Yes, creating threads is heavyweight. (very) There are different approaches to communicate between threads, but all the approaches creates threads in the beginning and kill thems at the end. Sometimes threads are killed after a specified amount of process just "in case". (apache does that I think... on processes). I hope it helps. --- Peter Drake <[EMAIL PROTECTED]> escribió: > I'm afraid I don't follow you. I THINK I'm doing > what you describe. > My Player object creates several threads, each of > which plays a game. > After all of the games are completed, the main > thread incorporates > them into the search tree. Here's the Java: > > timer.schedule(interrupt, MSEC_PER_MOVE); > while (!currentThread().isInterrupted()) { > // Create and start the threads > for (int i = 0; i < NUMBER_OF_THREADS; i++) { > runnables[i].prepareForLongUndo(); > threads[i] = new Thread(runnables[i]); // I > suspect this is the > expensive part > threads[i].start(); > } > // Wait for all of the threads to finish (code > omitted) > // Incorporate games > for (int i = 0; i < NUMBER_OF_THREADS; i++) { > incorporateRun(runnables[i].getBoard()); > runnables[i].longUndo(); > } > } > > The problem is that a single MC run takes about 1/5 > of a millisecond, > so it's not worth the overhead of putting it off > into another thread. > I need some way to tell a thread to do many runs, > then somehow > incorporate the multiple runs back into my search > tree. I believe > others are already doing this and I'm curious how. > > Remi? Sylvain? > > Peter Drake > Assistant Professor of Computer Science > Lewis & Clark College > http://www.lclark.edu/~drake/ > > > > > On Dec 7, 2006, at 9:41 AM, steve uurtamo wrote: > > >> Those of you with multithreaded UCT programs -- > how > >> do you do it? > >> Doesn't UCT pretty much require updating a common > >> data structure > >> after each MC run? > > > > you could hand a job (starting position) to each > > thread and have the thread manager update a shared > > memory segment that they all can read from (but > not > > write to). > > > > or are you talking about networked threads? > > > > s. > > > > > > > > > ______________________________________________________________________ > > > ______________ > > Have a burning question? > > Go to www.Answers.yahoo.com and get answers from > real people who know. > > _______________________________________________ > > computer-go mailing list > > computer-go@computer-go.org > > > http://www.computer-go.org/mailman/listinfo/computer-go/ > _______________________________________________ > computer-go mailing list > computer-go@computer-go.org > http://www.computer-go.org/mailman/listinfo/computer-go/ > __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar _______________________________________________ computer-go mailing list computer-go@computer-go.org http://www.computer-go.org/mailman/listinfo/computer-go/