• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

T3.java

Go to the documentation of this file.
00001 
00002 /**
00003  *  The class <code>T3</code> extends <code>T1</code> class.
00004  *  It is a test wrapper for <code>T1</code> and <code>T2</code> classes
00005  *  according to the following specification:
00006  *  <pre>
00007  *   1. Create and start thread from class T1
00008  *   2. Wait 5 seconds
00009  *   3. Create and start thread from class T2
00010  *   4. Wait 5 seconds
00011  *   5. Pause thread from class T2
00012  *   6. Wait 5 seconds
00013  *   7. Activate thread from class T2
00014  *   8. Wait 5 seconds
00015  *   9. Kill thread from class T1
00016  *  10. Wait 5 seconds
00017  *  11. Kill thread from class T2
00018  *  </pre>
00019  *
00020  *  @author Mikica B Kocic
00021  */
00022 public class T3 extends T1 
00023 {
00024     private String signature = "T3: Thread 3";
00025     
00026     private float initialDelaySec = 0f;
00027     
00028     /**
00029      * Creates a new instance of T3.
00030      */
00031     public T3( JPWorld component, float sleepIntervalSec, float initialDelaySec )
00032     {
00033         super( component, sleepIntervalSec );
00034         this.initialDelaySec = initialDelaySec;
00035     }
00036 
00037     /**
00038      *  Test procedure for T1 and T2 classes running in separate thread.
00039      */
00040     @Override
00041     public void run ()
00042     {
00043         interruptibleSleep( (int)( initialDelaySec * 1000f ) );
00044         
00045         parent.clearLogArea (); // clear log area first
00046 
00047         parent.println( signature + ": Running..." );
00048 
00049         interruptibleSleep( 1000 );
00050         
00051         parent.println( "------ Creating T1" );
00052         T1 t1 = new T1( parent, 1.0f );
00053 
00054         parent.println( "------ Starting T1" );
00055         t1.start ();
00056 
00057         interruptibleSleep( 5000 );
00058         
00059         parent.println( "------ Creating T2" );
00060         T2 t2 = new T2( parent, 1.0f );
00061 
00062         parent.println( "------ Starting T2" );
00063         t2.startThread ();
00064         
00065         interruptibleSleep( 5000 );
00066         
00067         parent.println( "------ Disabling T2" );
00068         t2.disableThread ();
00069         
00070         interruptibleSleep( 5000 );
00071         
00072         parent.println( "------ Enabling T2" );
00073         t2.enableThread ();
00074         
00075         interruptibleSleep( 5000 );
00076         
00077         parent.println( "------ Killing T1" );
00078         t1.stopThread ();
00079         
00080         interruptibleSleep( 5000 );
00081         
00082         parent.println( "------ Killing T2" );
00083         t2.stopThread ();
00084         
00085         parent.println( signature + ": Done." );
00086         parent.afterTestsCompleted ();
00087     }
00088 }

Generated on Thu Dec 16 2010 12:28:54 for Multi-threaded World of Particles by  doxygen 1.7.2