in reply to RE: Threads vs forking
in thread When is a while not a while?
Where locking is necessary is when two things (threads, processes, machines in a cluster, whatever) need to synchronize access to the same resource. Think here of Highlander - allow only one invocation at a time of an expensive CGI script, or also think of some CGI script that updates some user file. If your user submits twice you now have 2 processes, one of which might be reading while the other is deleting...
That is a race condition. If the first cleanly read, rewrote, and exited, you would be fine. The second likewise. If they collide...
It just happens to be really easy for two threads to collide. And much less common for programs to do it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Just enough to be dangerous (on threads) indeed! :-)
by lhoward (Vicar) on Aug 25, 2000 at 22:27 UTC | |
by tilly (Archbishop) on Aug 25, 2000 at 22:33 UTC | |
by lhoward (Vicar) on Aug 25, 2000 at 22:59 UTC |