Page 159 - CTS - CSA TP - Volume 2
P. 159

COMPUTER SOFTWARE APPLICATION - CITS




           Step 1: Create a Thread class
































              •  A new class named MyRunnable is defined, and it implements the Runnable interface.

              •  The class includes a private field message and a constructor to set its value.
              •  The run method is overridden from the Runnable interface. It contains a loop that prints the thread name,
                 the message, and a loop variable.

           Step 2: Create the main class (ThreadExample)












































                                                           144
                                CITS : IT & ITES - Computer Software Application - Exercise 103
   154   155   156   157   158   159   160   161   162   163   164