Java threading
by Sue
If you were to explain threading in java to a 3 yr old how would you do it. Top 3 best answers (polled so I would have ideas on what to doodle):
a thread is like a little machine
you give it stuff
it does it
if you have many threads, you need to make sure they dont crash into each other
think go carts, not bumper cars
Threading is like a bunch of killer hyena you send to viciously hurt an enemy. You never want them to Kill the same person because they can kill each other
threading is like having a bunch of dogs to play fetch with
but you don’t want them going after the same ball

In java you have Processes and you have Threads. Processes are a self contained execution environment. They have their own memory. Think CTL+Alt+Del when you want to see what’s making your computer slow as hell, only to find out you have 13 instances of Firefox running for no reason. Those are all processes.
Threads are lightweight processes. Processes and threads are both execution environments, but creating a new thread requires fewer resources than creating a new process. You can have threads inside a process and most processes have one. They chare the resources inside the process (e.g. files & memory). You can have multithreaded execution, but you need to make sure that the threads aren’t trying to use the same resource (e.g. little machines not crashing into each other, hyenas not going after the same victim, dogs not going after the same ball) or everything will crash and burn.
TO BE CONTINUED… (and updated with code examples)
I’m posting this just so no one thinks I am some sort of Obese spiderman fetishist.
Damn inside jokes.
I am waiting until my class is over to post homework examples, just in case my classmates are trolling the web for answers.