21
votes

If you have to explain the concept of multi-threading to a seven year old kid how would you do it? I recently got this question in an interview. I came up with a story using jobs (the task to be done) and workers (the threads) but it was not entirely convincing (considering the kid is too young).

If you were asked to describe this, how would you do it?

20
  • 55
    I would ask the interviewer if he/she was planning on hiring any 7 year old children.
    – Craige
    Mar 3, 2011 at 18:30
  • 14
    I would have Punched the Interviewer in the Face.
    – Morons
    Mar 3, 2011 at 18:36
  • 11
    It's probably to test that you know the subject well enough to teach it to someone who has absolutely no knowledge of the subject. Mar 3, 2011 at 18:36
  • 6
    @Morons First of all, that's a bit violent. Second of all, are your Words Capitalized because of any Special Meaning?
    – Nicole
    Mar 3, 2011 at 18:40
  • 11
    @FrustratedWithFormsDesigner Well, it's bloody stupid. Can you explain complex numbers to someone who doesn't know how to count? No? You're rubbish at complex numbers then.
    – biziclop
    Mar 3, 2011 at 19:14

19 Answers 19

35
votes

Describe what it is, just leave out the technical terms except for definitions:

  1. You have five jobs to do. You need to start working on all of them right now.
  2. Each job is a thread.
  3. You are the processor.
  4. Spend a little bit of time working on each job and then move to the next one, making sure you give attention to all of them.
  5. If you have more people, a job can only be worked on by one person at a time.
  6. Since each person can work on a different job, more people can get all the work done faster, if you have more than one job.
9
  • 15
    I think the only thing I'd add is maybe change "jobs" to "games" or playing with toys or doing chores or homework. Mar 3, 2011 at 18:39
  • Then if you have 'the processor' 'keep notes' when they're working on a job, you can explain cache and cache coherency in a multiple processor env Mar 3, 2011 at 19:13
  • Good description, but knowing 7 year olds, this won't fly.
    – red-dirt
    Mar 3, 2011 at 22:36
  • @el fuser I am a 7 year old! or atlest i ac lke 1 hahahahahaha Mar 4, 2011 at 1:06
  • @bethlakshmi, your assuming that at 7 most kids are still playing games and haven't gone out and got productive jobs yet? come on! Mar 4, 2011 at 2:25
22
votes

Hey Kid. Have you ever walked and chewed gum at the same time while thinking about Pokemon? That's your brain multi-threading.

4
  • 1
    That's your brain's peripherals being able to act relatively independently. It's (almost) like your brain using DMA.
    – Nick T
    Mar 4, 2011 at 1:32
  • @nick T, more like cloud computing with only no source code access to the components. Even the person chewing the gum has no idea how they are actually performing the action. Mar 4, 2011 at 2:27
  • @Ano, your last statement seems to reinforce my peripheral analogy. The peripheral does stuff without the CPU delving into the minutiae, just simply delegating it. I guess you could also say it's like cloud computing, but that's on a much larger scale; DMA and peripherals are fairly low-level.
    – Nick T
    Mar 4, 2011 at 3:31
  • really? I would have thought playing pokemon (higher order problem solving) would have definately required user mode memory and the use of a higher level programming language, but perhaps something like masticulating could be DMA. Mar 4, 2011 at 3:35
10
votes

Relate it to something they can easily understand. Cars on a road.

Think of a single lane road. With 12 cars on it, they drive one after another. And only one car can finish at the same time, and a faster car, can't pass the slower ones.

But, with multi-threading, it's like all those cars are driving on a wide road with four lanes. The faster cars can go past the slower ones.

Edit: and, if they aren't careful, they can crash into each other...

2
  • 4
    If multi-threading is a road, then it's one where when one car is driving, the other isn't moving at all - not following behind it...
    – Nicole
    Mar 3, 2011 at 20:51
  • @Renesis, good point, I suppose I could change the example to a narrow bridge that only one car can cross at a time because two cars would be two heavy...
    – CaffGeek
    Mar 3, 2011 at 21:27
10
votes

I would explain it like doing the laundry.

You have 3 loads of laundry, and one washer and one dryer.

The way everyone does laundry is to move the first load into the dryer than put the next load for washing.

Any kid would understand that waiting for the first load to dry before starting washing the second load would take more time.

You could even take it a step further by explaining if you have more washers and dryers (like at a laundromat), you can do the loads faster.

2
  • 2
    Additionally you can't dry the laundry until a load has gone through the washer, so you can also describe blocking
    – zzzzBov
    Mar 3, 2011 at 20:33
  • I almost gave you a +1 but then I realised that no kid in their right mind would follow this explanation. For starters you used something extremely boring (from the kids perspective not mine) which is a chore. As soon as you say the word laundry their mind switches off, they literally would only hear the first 7 words. Mar 4, 2011 at 3:37
6
votes

Cooking a meal with several dishes on a small stove. You have two burners (i.e. processors or cores) and four dishes (threads) to cook. So only a maximum of two dishes can be cooked (run) at a time. Different dishes have different cooking times. The cook (the OS) has to juggle all of this so everything gets cooked in time for dinner.

3
votes

A circus juggler starting with two balls and gradually adding more and more balls to his or her act.

1
  • This is the best answer because it answers the question from the perspective of a 7 year old kid, not a 30ish programmer. Mar 4, 2011 at 3:37
2
votes

In my experience 7 year olds have no problems with the concept of different things going on on the same time, which is witnessed by the various programming toolkits designed for kids. Notably the Lego kits, but also the Scratch system.

Perhaps the interviewer was simply trying to find a new angle on asking you something unexpected.

2
votes

"I need you to carry two glasses from the kitchen to the table. (They run, carrying a glass in each hand.) Now, please do it again, but only use one hand."

2
votes

Some of these answers are mind-blowing... I think I might be the only one here that knows 7 year olds???

So, Johnny... Multi-threading is similar to what happens when it's clean up time at school. All of your class needs to clean up after the end of the day... Each kid is basically a thread... picking up toys is the task, and the toy box is a shared resource.

Overall I think punching the interviewer in the face is a better answer.

2
  • whoever marked this -1 is kidding themselves. seriously grow a sense of humour. It's a ridiculous question that should be treated in that light. Mar 4, 2011 at 2:32
  • This is probably one of the best answers hear so far. It takes the concept and puts it in terms the listener understands - even if the listener has no idea how to code a multithreaded app, they will now understand the basic idea. Mar 4, 2011 at 14:35
2
votes

Multi thread, it's like having many things to do at a time, and do them little by little.

Hey the young curious guy, every day you must eat, play & sleep; right? But why don't you eat once... take a lot until you can't take more, then sleep all the time you need, then just play & play interesting games?

Well, you can't do that, because if you don't eat, you'll get hungry, no matter how much you got in the previous meal. If you don't sleep, you'll be tired and can't play with your friends. Understood? There's several things that need to be done, but we can't do them at once. We eat breakfast, play game, take lunch, play games again,... and says "good night" at last.

That's also the way a computer work: they play the music a little, then switch to the picture which you are drawing, then switch again to play music. But the time it took to do all of those things a thousand time is just a wink of eye, so you can't see it.

1
vote

You have a set of 6 tasks you have to do:

  • do your homework
  • clean up your room
  • do the shopping
  • pick the apples in the garden
  • wash the dishes
  • sweep the porch

Each task takes 1 hour to do. You have 2 brothers.

  • If you don't use multitasking, it means you have to do all the work by yourself. It will take you 6 hours (if you start at 12:00, all tasks will be completed at 18:00).
  • If you use multitasking, it means you can give some tasks to your brothers. If you all start working at the same time, you will finish all the tasks sooner. In this case, all 3 of you will do 2 tasks each, which will take 2 hours (if you all start at 12:00, all tasks will be completed at 14:00!).
0
votes

You've got one joystick/game controller.

There are 4 kids. Each kid takes a turn playing each level while the others rest. Using teamwork, they eventually reach level 255 *.

While each kid is playing, he's also eating from the bag of chips that only the current player is allowed to eat from.

*Then the game crashes. ;)


"Why don't you buy 3 more controllers?"

Well, those are multiple processors!

0
votes

Art class (Multi-threaded application)

Since there can be no class without a teacher, you need a teacher (main thread). When you get to class you sit down and the teacher accounts for everybody and assigns the class to paint pictures for the day.

The teacher assigns all the students for the day to start painting (thread initialization and assignment).

Because the school only has so many paints, everybody is going to have to share colors with each other (paints represent memory).

Lets say you're painting a dragon and you want to give it crazy red eyes but somebody else is using the red paint. You can't just go over and take the paint for yourself because then nobody else would be able to use it. Instead, what you do is you politely ask to share (resource locking) the paint. You use a little, then pass it along. You may have to wait a bit to get it back but it allows everybody who needs it to get some without a paint fight (race conditions).

At the end of the class the teacher dismisses the class (thread joining).


Gaming (Multi-process application)

Playing a card game with friends (or equivalent game with collectibles):

Lets say you get together with your friends (processes) after school. There are no teachers around to nobody is there to tell you what to do.

Everybody is gets together to play games (multi-process or multi-layered application).

You think hard about how you can use your cards to beat your opponents (internal processing) and you try to share ideas with your partner when you come up with an idea (message passing).

If you get really good you may join a club:

Leader (executive program) Members (subprograms)

If the club gets really good they may come up with a special way (API) to communicate with each other to help strategize better.


I chose not to mention multiple processors/cores here because the abstraction gets pretty complicated (and context switching is still transparent to most applications). I could probably start by saying that every team in the game represents a separate processor/core and most games still suck because they only allow a few teams to play together in a game. The future may look something more like an MMORPG where many people can play together in a game on many different teams.

Trying to develop a kids metaphor for a distributive processing system on a many core computer or many host network would be pretty interesting to play with but that's not what the Op asked for.


Note:

Message passing above is a reference to the many forms of communication that programs use to talk to each other. Like people, applications have many ways to talk to each other. Writing is like Piping serialized data, talking is like networking, whispering is like networking over an encrypted connection, databases are like a score card (finite structure with well defined data), and using MSMQ is like tapping morse code by bashing your head against a solid surface.

Most other forms of communication beyond that blur together too much for me to consider them indistinguishable.

Aside:

If you've ever played an online game like Halo, the people who join groups (or become pro players) usually have a shortened language to give call outs to direct each other where the other team's players are and what they're using. It's really obnoxious if you don't know the call outs but it's surprisingly effective during game play.

It's interesting how, even though most people that live within a given culture speak a common language but within that culture people develop shorter succinct domain languages that are optimized to handle specific tasks. In computing I'd compare that to an API.

-1
votes

Use a widely adopted model: the dining philosophers.

5 Philosophers eating their pasta dinner.

5 Forks available around the table.

Each philosopher needs two forks to eat.

Some eat. Some philosophize while waiting.

7
  • 2
    Philosphers eat with two forks? Man, they're even stranger than I thought! :P This story makes more sense with chopsticks instead of forks... Mar 3, 2011 at 19:02
  • 4
    @Frustrated, that is why they need to think so much.
    – user1249
    Mar 3, 2011 at 19:04
  • I don't think replacing chopsticks with forks works to well. :)
    – Tyanna
    Mar 3, 2011 at 20:20
  • 4
    I like the chopsticks analogy better. You definitely need two chopsticks to eat. You don't really need two forks. The forks thing actually confuses the issue. Especially since forking is a key term in multiprocessing.
    – Paul Sasik
    Mar 4, 2011 at 1:04
  • .. and then your stuck explaining what a philosopher is. And of cause they will ask why they need two forks (which is kinda dumb from a 7yo's perspective) and why of cause anyone would wait before eating! Mar 4, 2011 at 3:39
-1
votes

Suppose you're (the kid) bouncing a ball on your head. After every bounce, you're counting it, i.e., number of bounces. Also after every bounce you're saying the letters from alphabet (A, B, C, ...)

Kid, you're multithreading.

-1
votes

Spinning plates is a good example. Think of those magician people who take some plates and get them spinning all at the same time. The magician is constantly switching between plates to ensure they all stay spinning.

-2
votes

A computer can really only work on one thing at a time, but it can do things very quickly. (I'm leaving out multi-core processing for simplicity.) But what if you want to listen to music and play a game at the same time? The computer (very rapidly) switches between handling the music and handling the game.

1
  • "But why doesn't it do both at the same time?" Mar 4, 2011 at 1:16
-2
votes

Our local playground has a triple slide and a single slide. Threading is like the triple slide, 3 kids can slide down simultaneously. But on the single slide two kids have to wait at the top for the first kid to go down the slide.

Was part of the job description reporting to the CFO?

-3
votes

Two kids in a playground sharing (fighting over) limited resources, say the required lego pieces from a small box to make their favorite robots.

Not the answer you're looking for? Browse other questions tagged or ask your own question.