Alex Rivera | Logout

What's harder, synchronizing 2 threads or 1000 threads?

Asked 2010-07-29T12:45:39.030
11

On Paul Tyma's presentation, I found an interview question:

What's harder, synchronizing 2 threads or synchronizing 1000 threads?

From my perspective, of course synchronizing 1000 threads is harder, but I can't think of a good reasons for that beside 'of course'. But since it's interview question, may be I'm wrong (interview questions have to be tricky, isn't it?).

Edit
Report

2 Answers

3

Why would synchronizing 1000 threads be any harder than synchronizing 2 threads?

The only code that would be added would be to spawn the extra threads.

You wouldn't have to add any synchronization code (as long as you were doing everything correctly).

answered 2010-07-29T12:48:21.443
3

It depends what "is easier" means. The complexity of the design/locking mechanisms is roughly the same.

That being said, I think 1000 thread programs might be easier to debug. Vulnerable race-conditions have a higher probability of occurring and will probably be easier to replicate. A race condition in two threads might only appear once every 5 years if the moon is full and you're on vacation.

answered 2010-07-29T13:04:46.847

Your Answer