That's also quite simple. You can run threads (we call them shreds) next to the main one. You define those as functions and you "spork" the function. ======================================= //let's define a function fun void paralel() { while(true) { //this will loop forever <<<"beep">>>; second => now; } }
//let's try sporking it spork ~ paralel();
//now we write the main loop that will run next to it while(true) { //this will also loop forever <<<"boop">>>; .75::second => now; }
//anything that you would write here will never get executed because the program will always be stuck in that last loop. you could still define functions here though.
-----------------------------
See? not at all hard. You can run as many functions next to eachother as you like, they can all be different or they could all be the same. If they are all the same you only need to define it once and can spork it as many times as you'd like (untill the cpu gives up! Notice that they can all run at different speeds if you'd like, in my example above one loops in .75 seconds while the other takes a whole second so they will drift in and out of phase.
Cool! Thanks!