< Zurück | Inhalt | Weiter >

18.3 MasterControl

The MasterControl class is Java 3D’s central message dispatch and thread scheduling mechanism. The MasterControl object is a static member of the VirtualUniverse class, and is initialized by a static initializer on the VirtualUniverse class. All instances of the VirtualUniverse class therefore share the same MasterControl instance.


The first time a message is posted to the MasterControl class, it creates the MasterControlThread. The MasterControlThread runs the main message−processing loop for the MasterControl class.

image


Figure 18.1 Native (Windows) threads running a Java 3D application


Master Root Thread Group Name: Java3D Thread Name: J3D−MasterControl

class MasterControlThread extends Thread

{

MasterControlThread(ThreadGroup threadgroup)

{

super(threadgroup, "J3D−MasterControl"); VirtualUniverse.mc.createMCThreads(); start();

}

public void run()

{

do

while(VirtualUniverse.mc.running)

{

VirtualUniverse.mc.doWork(); Thread.yield();

}

while(!VirtualUniverse.mc.mcThreadDone());

}

}


image


The constructor for the MasterControl class loads the J3D.DLL native DLL and reads the Java 3D system properties (see table 18.4).


 

Message processing and threading architecture
J3dMessage