Object Hierarchy
What is it?

A Thread contains a block of code that can be run concurrently with other code.

Quick Example
thread = [Thread new: { io putLine: "I'm in a thread!" }]

Table of Contents:

Constructing a Thread

A Thread is created with the Thread#new: method, with a Block as the argument:

key => value

Thread Scope

A Thread has access to global variables, variables passed into the block, and variables created within its block. A Thread’s scope is not breakthrough.

variable = 1

// accessing 'variable' inside this thread will produce an UnidentifiedObjectException
Thread new: { variable }

// but we can access a global variable inside a thread
global newVariable = 2
Thread new: { variable2 }

put example of variables passed into a block here hor hee

Thread Lifetime

A Thread’s lifetime is dictated by the lifetime of its block. A Thread can be prematurely stopped by the kill method:

thread = [Thread new: {
             while (true)
                 io putLine: "i'm never leaving! na na na"

thread start

// why is the thread taking so long? let's kill it
thread kill