home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / samples.z / CounterThread.wxc < prev    next >
Text File  |  1997-01-28  |  2KB  |  115 lines

  1. Save Format v2.0(1)
  2. @begin ClassFile "CounterThread"
  3.  Exported 1;
  4.  Abstract 0;
  5.  Interface 0;
  6.  PackageName "";
  7.  Language "Java";
  8.  
  9.  @begin UserFunction "CounterThread(threads2 parent)"
  10.   GencodeSrcLine 10;
  11.   FunctionName "CounterThread::CounterThread(threads2 parent)";
  12.  @end;
  13.  
  14.  @begin UserFunction "Prototype for CounterThread(threads2 parent)"
  15.   Private 1;
  16.   GencodeSrcLine -1;
  17.   FunctionName "CounterThread::Prototype for CounterThread(threads2 parent)";
  18.  @end;
  19.  
  20.  @begin UserFunction "run()"
  21.   GencodeSrcLine 23;
  22.   FunctionName "CounterThread::run()";
  23.  @end;
  24.  
  25.  @begin UserFunction "Prototype for run()"
  26.   Private 1;
  27.   GencodeSrcLine -1;
  28.   FunctionName "CounterThread::Prototype for run()";
  29.  @end;
  30.  
  31.  @begin HPPPrefixBlock
  32. @begin-code HPPPrefix
  33.  
  34. // add your custom import statements here
  35.  
  36. @end-code;
  37.   GencodeSrcLine 6;
  38.  @end;
  39.  
  40.  @begin ClassContentsBlock
  41. @begin-code ClassContents
  42.  
  43.     // add your data members here
  44.     Form1 _parent;
  45.     int _threadNumber;
  46.     int _counter = 0;
  47.  
  48. @end-code;
  49.   GencodeSrcLine 38;
  50.  @end;
  51.  
  52. @begin-code BaseClassList
  53.  
  54. extends Thread
  55.  
  56. @end-code;
  57.  
  58. @begin-code GeneratedClassContents
  59.  
  60.  
  61. @end-code;
  62.  
  63. @begin-code Code "CounterThread::CounterThread(threads2 parent)"
  64.  
  65. /******************************
  66. /**
  67.  * This class constructs the counting threads.
  68.  * The thread counts from 0 to 1000 (then rolls over) and
  69.  * displays the count value on the parent form.
  70. */
  71.  
  72.     public @CLASSNAME@(Form1 parent, int threadNumber)
  73.     //********************************
  74.     {
  75.         _parent = parent;
  76.         _threadNumber = threadNumber;
  77.     }
  78.  
  79. @end-code;
  80.  
  81. @begin-code Code "CounterThread::Prototype for CounterThread(threads2 parent)"
  82.  
  83.     public:
  84.         @@CLASSNAME@(threads2 parent);
  85.  
  86. @end-code;
  87.  
  88. @begin-code Code "CounterThread::run()"
  89.  
  90.     public void run()
  91.     //********************************
  92.     {
  93.         while (true) 
  94.         {
  95.             _counter = _counter + 1;
  96.             if (_counter > 1000)
  97.                 _counter = 0;
  98.             synchronized (this)
  99.             {
  100.                 _parent.setCounter(_threadNumber, _counter);
  101.             }
  102.         }        
  103.  
  104.     }
  105.  
  106. @end-code;
  107.  
  108. @begin-code Code "CounterThread::Prototype for run()"
  109.  
  110.     public:
  111.         void run();
  112.  
  113. @end-code;
  114. @end;
  115.