
Writing Multithreaded Code Is Like Juggling Chainsaws - davidblair
http://thecodist.com/article/writing-multithreaded-code-is-like-juggling-chainsaws
======
jws
Apropos _Juggling Chainsaws_ , (but not this post) From an article about "Mad
Chad"…

 _Tim Newman, a commercial director and cousin of Grammy-winning musician
Randy Newman, asked if I could juggle chainsaws? In my naïve enthusiasm I said
sure. I had opened my big mouth and the clock was ticking, with only 10 days
to figure out how to juggle a live chainsaw without seriously injuring or
killing myself. The first four days I was so nervous that I wouldn’t even
start the chainsaw. Finally I pulled the cord and on my first attempt, I
missed. The chainsaw hit the ground and went crazy, buzzing at full speed. Two
policemen ran up and asked, “What the hell are you doing, kid?” I explained my
dire situation and they thought it was cool. They began cheering me on. They
wanted to see me do it!

On shoot day I show up for the commercial and get prepared. I fire up the
chainsaw and Tim Newman says, “Whoa, what are you doing?” Long story short,
after 10 days of practice, I find out they didn’t want the chainsaw running
during the commercial (insurance won’t cover a stunt like that). The plan was
to just add the sound effect in post-production. I felt a little stupid but it
turned out to be the best mistake I ever made. The seed had been planted and
soon I was juggling three saws at the same time. No one in Venice was doing a
more extreme act._

There is a lesson about requirements gathering in there somewhere, and
probably one about stepping outside your comfort zone.

Whole article: <http://www.venicebeachbook.com/vbb2c.html>

------
motters
Indeed. And this is why I think the current multithreading paradigm isn't
going to scale well when we start getting into tens and hundreds of CPU cores.
Something is going to have to change.

------
drtse4
Completely agree, i've dealt myself with an access bottleneck as the one he
describes. But i found multi-threaded code debugging quite entertaining
(sometimes ;)).

~~~
ajross
Agreed. Writing low-level synchronization code is hard and error prone. It's
almost always worthwhile to burn some extra memory or CPU to choose a solution
that's multiprocess instead, or just eat the performance/scalability cost of
traditional serialized code.

But it's a _ton_ of fun when you get it right. Sort of the "cycle counting" of
the modern world.

------
DanielBMarkham
I agree.

I'd like to point out that the use of immutable data structures solves some
threading issues. Unfortunately, as in this example, it's easy to get hung up
somewhere in your technology stack without realizing what's going on.

