6 · Advanced · lesson 33 of 41

Threads & Runnable

Multiple flows of execution inside one JVM.

Java
Thread t = new Thread(() -> {
    for (int i = 0; i < 5; i++)
        System.out.println("tick " + i);
});
t.start();       // runs concurrently
t.join();        // wait for it
TIP
The 3D scene shows two threads racing on a shared counter — watch it lose updates without synchronization.
Loading 3D scene…
Key takeaways
  • ✓start() spawns; run() would be sequential.
  • ✓Multiple threads share heap objects — that's where the trouble starts.