CSC 216/s08/but one lamp: Difference between revisions
(Ok, joke has become old.) |
No edit summary |
||
Line 2: | Line 2: | ||
[http://meta.wikimedia.org/wiki/Help:Wikitext_examples Formatting Help Guide from MetaWiki] | [http://meta.wikimedia.org/wiki/Help:Wikitext_examples Formatting Help Guide from MetaWiki] | ||
== | ==An Introduction to Threads== | ||
This project will introduce threads to students who have no previous knowlage on the subject. | |||
=== | ===What are Threads?=== | ||
Threads are a way to break up your machine's processing so it can do many tasks all at the same time. These tasks are able to share variables, moniter each others progress, and begin and terminate seperatly. | |||
===Participants and props=== | ===Participants and props=== | ||
For this two work, six students with a healthy desire for compotion will have to be chosen from the class. The only required materials are two decks of playing cards and a table to sit around. | |||
=== | ===How it works=== | ||
First the teacher should get out two sets of cards, remove the jokers, and shuffle well. He should then get a single volunteer from the class and hand him one of the decks. Next, the teacher should find five more students ready to compete against the other student giving one of the other students the second deck. The teacher will instruct the single student that when he says go, that student should sort the card into suite and then from 2 to Ace by suite. He will then instruct the group of five that when he says go, the student with the deck, the Driver, should count out exactly thirteen cards and give it to one of his fellow students, a thread. He should repeat until all the cards are given out. As soon as a thread gets a deck it may begin to sort it into suite and place it in the middle of the table where the threads shared variables go. The thread may not pick up any cards unless handed by the driver and may begin it's task as soon as it recieves cards without having to wait. Once all threads have terminated the suite sort, the driver may then give each thread a stack to sort from 2 to Ace. The group of five people should finish much faster than the single person. | |||
This simulation should show that by breaking it up processing in such a way, threads can accomplish some tasks faster than a single program. The teacher should then go on and teach some of the more intricaces of threads. |
Revision as of 18:41, 15 April 2008
Formatting Resources
Formatting Help Guide from MetaWiki
An Introduction to Threads
This project will introduce threads to students who have no previous knowlage on the subject.
What are Threads?
Threads are a way to break up your machine's processing so it can do many tasks all at the same time. These tasks are able to share variables, moniter each others progress, and begin and terminate seperatly.
Participants and props
For this two work, six students with a healthy desire for compotion will have to be chosen from the class. The only required materials are two decks of playing cards and a table to sit around.
How it works
First the teacher should get out two sets of cards, remove the jokers, and shuffle well. He should then get a single volunteer from the class and hand him one of the decks. Next, the teacher should find five more students ready to compete against the other student giving one of the other students the second deck. The teacher will instruct the single student that when he says go, that student should sort the card into suite and then from 2 to Ace by suite. He will then instruct the group of five that when he says go, the student with the deck, the Driver, should count out exactly thirteen cards and give it to one of his fellow students, a thread. He should repeat until all the cards are given out. As soon as a thread gets a deck it may begin to sort it into suite and place it in the middle of the table where the threads shared variables go. The thread may not pick up any cards unless handed by the driver and may begin it's task as soon as it recieves cards without having to wait. Once all threads have terminated the suite sort, the driver may then give each thread a stack to sort from 2 to Ace. The group of five people should finish much faster than the single person.
This simulation should show that by breaking it up processing in such a way, threads can accomplish some tasks faster than a single program. The teacher should then go on and teach some of the more intricaces of threads.