Programming language: JAVA / Android
Thread “Structure”
Main Thread (starts other treads)
—(multiple attributes)
—AI thread
—TouchListener thread
—Scripting thread
—Render thread
Description
An example for an attribute would be an actor that is instructed by the scritping thread;
has it’s route calculated by the AI thread and the 3D coordinates changed by the renderer.
All the threads are NOT private inner classes with access to the attributes, instead they are simple classes which implement Runnable
Question
How to share objects (the attributes) between those endlessly running threads?
Every thread must have access to all the resources of the main thread.
(the question is not about how to syncronize them, I know “syncronized” and the concept of locks already)
You may create a class SimulationModel which is instantiated by Main thread/class and provided to others by a setter or by their constructor.
This class contains all the data and own the locks to maintain consistency.
The logic about data manipulation may take place here too.