News for hackers. Stuff that matters.
Re:Make your program slower with threads by blt on Sunday December 07, 2014 @02:28AM (#8711563)
Yes, I thought rand()'s self-locking was pretty common knowledge, but it is a good example to teach the perils of multithreading because its signature gives no indication that anything bad will happen. strtok() is even worse.

C++11's excellent <random> library represents the PRNG as an object like it should. Besides making the statefulness of PRNGs explicit, its API encourages correct usage - it would be more work to share a PRNG between threads.

Re:Make your program slower with threads by Animats on Sunday December 07, 2014 @02:44AM (#8711586)
strtok() is even worse. (Because it has global state)

There are a lot of C standard library functions from the 1970s that should have been moved to a "deprecated" library around 1990 or so and phased out by now.

Re:Make your program slower with threads by vardump on Sunday December 07, 2014 @09:26AM (#8712233)
Throw zero-terminated strings away too, please. Scanning sequential bytes is very slow and has caused so many bugs.