Anonymous user
Concurrent computing: Difference between revisions
Added Java example edited from fork process
m (Should have previewed that...) |
(Added Java example edited from fork process) |
||
Line 100:
process2 = putStrLn "Rosetta"
process3 = putStrLn "Code"
=={{header|Java}}==
public class Threads{
public static void main(String[] args){
Thread enjoy =
new Thread(){ //anonymous class definition
//this overridden method counts once every second up to five
public void run(){
System.out.println("Enjoy");
}
};
Thread rose =
new Thread(){ //anonymous class definition
//this overridden method counts once every second up to five
public void run(){
System.out.println("Rosetta");
}
};
Thread Code =
new Thread(){ //anonymous class definition
//this overridden method counts once every second up to five
public void run(){
System.out.println("Code");
}
};
//these will probably (but not definitely) run in the order they are called since the runnable code is so short
enjoy.start(); //calling .run() will not run it in a new thread
rose.start();
code.start();
}
}
=={{header|JavaScript}}==
|