Commit 23e51ccd authored by Christoph Gerum's avatar Christoph Gerum

Added a simple multithreadded java example

parent 859b7b5d
class Hello {
private static class MyRunnable implements Runnable {
public MyRunnable(int id){
this.id = id;
}
public void run(){
System.out.println("Hello from thread " + id );
}
public int id;
}
private static int num_threads = 2;
public static void main(String[] args) {
Thread t[] = new Thread[num_threads];
for(int i = 0; i < num_threads; i++){
t[i] = new Thread(new MyRunnable(i));
t[i].start();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment