It may execute sequentially to the end, or it may spawn separate threads of control and optionally rejoin them at any point in its execution. All barriers, broadcasts, exchanges, reductions and scans take place only among the threads that make up a particular ThreadGroup. ThreadGroups are defined by their Runnable class and time of birth. If two ThreadGroups are spawned on the same Runnable class but at different times, for all intents and purposes, they are two distinct ThreadGroups. ThreadGroup Communication Communication between ThreadGroups is an important topic which shall be discussed below.
Communication occurs via modification of shared variables.
These variables can be static fields, single static fields, local fields accessible via global pointers, or single local fields accessible via single global pointers. Synchronization is needed to prevent race conditions between threads in a ThreadGroup and between threads in competing ThreadGroups. Let's say we have a computation grid that is spread across the processing units of a ThreadGroup. Each grid point contains a data structure that holds our particles. On each computation step, a particle might feel a force due to its neighbors and move across the grid.