|
From: Benjamin G. <ben...@bt...> - 2001-05-23 20:12:07
|
On Wed, May 16, 2001 at 07:53:33PM +0100, Daniel Barron wrote: > With a MultiThreader() daemontest, is there a concurrency issue with the > handleConnection() code? I.e. does the for() i integer have a race > condition? Or is there a seperate copy of the TestDaemon class object > running in each thread and so is thread-safe? You needn't worry about `i'. There's no race condition, because `i' is a local variable; i.e. a new `i' is created and destroyed (on the calling thread's stack) within the scope of each handleConnection() method call. Thread safety is only an issue with class members and static variables. > Also I thought that sleep() caused the entire process to sleep and you needed > to call a pthread sleep? I think you're right; that should be a call to reliable_usleep(), an internal nb++ function that just sleeps the current thread (using select()). I'll fix it. > I hope I'm using the correct jargon for these questions! I'm new to the > concepts of multi-threading. It takes some getting used to. You might want to read something like _Programming with POSIX Threads_ by David R. Butenhof (the Addison-Wesley series tends to be quite good). -- Benjamin Geer http://www.btinternet.com/~benjamin.geer |