Coding Bootcamp: Threads

Processes and Threads

Threads

Provide a runnable object

 public class HelloRunnable implements Runnable {
    public void run() {
        System.out.println("Hello from thread!");
    }
    public static void main(String[] args) {
        (new Thread(new HelloRunnable())).start();
    }
 }

Subclass thread

public class HelloThread extends Thread {
    public void run() {
        System.out.println("Hello from thread!");
    }
    public static void main(String[] args) {
        (new HelloThread()).start();
    }
 }

Interrupts and Joins

Exercise 1

Exercise 2

a) the size of the collection and b) the collection's
contents by using the corresponding iterator.


Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.