Computer Chess Club Archives


Search

Terms

Messages

Subject: Threads

Author: James Robertson

Date: 18:30:34 04/06/99


I am thinking of making my program multithreaded to ease implementation of
several things. But before I begin, I have several questions: first, if I have
an input thread that just sits with cin, and my search thread is doing stuff in
the background, will the search thread be slowed? Second, about locking and
unlocking resources shared between threads; how is this usually done? If I just
declare a variable, say

bool locked = false;

Can I "lock" and "unlock" resources by just:

....

//see if the variable is locked
if (!locked) {
  locked = true;
  //change shared resources
  locked = false;
}

Will this work?

Any help is appreciated.
James

....



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.