-// init() is called during startup. Initializes locks and condition variables
-// and launches all threads sending them immediately to sleep.
-
-void ThreadsManager::init() {
-
- cond_init(sleepCond);
- lock_init(splitLock);
-
- for (int i = 0; i <= MAX_THREADS; i++)
- {
- lock_init(threads[i].sleepLock);
- cond_init(threads[i].sleepCond);
-
- for (int j = 0; j < MAX_SPLITPOINTS_PER_THREAD; j++)
- lock_init(threads[i].splitPoints[j].lock);
- }
-
- // Allocate main thread tables to call evaluate() also when not searching
- threads[0].pawnTable.init();
- threads[0].materialTable.init();
-
- // Create and launch all the threads, threads will go immediately to sleep
- for (int i = 0; i <= MAX_THREADS; i++)
- {
- threads[i].is_searching = false;
- threads[i].do_sleep = (i != 0); // Avoid a race with start_thinking()
- threads[i].threadID = i;
+// read_uci_options() updates internal threads parameters from the corresponding
+// UCI options and creates/destroys threads to match the requested number. Thread
+// objects are dynamically allocated to avoid creating in advance all possible
+// threads, with included pawns and material tables, if only few are used.