I think OP is trying to tackle too many concepts at once.
What you should understand first, Prinz, is what coroutines are, how they work, and how to use them with ComputerCraft. Coroutines are the foundations of all multitasking and windowing systems of computercraft.
A coroutine is essentially a lua function that can be paused and then resumed later by another function. There truly is no such thing as multitasking, just a bunch of different functions "passing the ball" per-say.
An example of single coroutine usage:
function hello()
print "Hello"
coroutine.yield()
print "World!"
end
co = coroutine.create(hello)
Here, we have a single coroutine, created from a simple function. To "run" this coroutine, we resume it.
coroutine.resume(co)
But if you run this in a lua prompt, you'll notice that it only prints "Hello". This is because of the coroutine.yield() call in the hello() function.
The function coroutine.yield() stops the current coroutine that is running at that very instance in time. In this example, we resumed the coroutine "co" created from hello(). It printed "Hello", then "paused" the function.
If you want it to print "World!", you need to resume it again:
coroutine.resume(co)
After resuming it a second time, the function prints "World!". If we try to resume it again, we get an error:
failed to resume a dead coroutine
Or something along these lines. Once a coroutine is done, it's done, and can never be resumed again.
In a real-world example, a multitasking system is just a bunch of ^those that are yielding themselves and being resumed by a loop of events. The function os.pullEvent() is essentially a wrapper for coroutine.yield().
If you want to know more about coroutines and how to use them, here are some resources:
ComputerCraft tutorial on CoroutinesCoroutines Tutorial on lua-usersCoroutine Function Reference (only for reference, not for learning)