home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / samples.z / CounterThread.wxc < prev    next >
Text File  |  1996-12-10  |  2KB  |  123 lines

  1. Save Format v1.3
  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 CPPPrefixBlock
  41. @begin-code CPPPrefix
  42.  
  43.  
  44. @end-code;
  45.   GencodeSrcLine -1;
  46.  @end;
  47.  
  48.  @begin ClassContentsBlock
  49. @begin-code ClassContents
  50.  
  51.     // add your data members here
  52.     Form1 _parent;
  53.     int _threadNumber;
  54.     int _counter = 0;
  55.  
  56. @end-code;
  57.   GencodeSrcLine 38;
  58.  @end;
  59.  
  60. @begin-code BaseClassList
  61.  
  62. extends Thread
  63.  
  64. @end-code;
  65.  
  66. @begin-code GeneratedClassContents
  67.  
  68.  
  69. @end-code;
  70.  
  71. @begin-code Code "CounterThread::CounterThread(threads2 parent)"
  72.  
  73. /******************************
  74. /**
  75.  * This class constructs the counting threads.
  76.  * The thread counts from 0 to 1000 (then rolls over) and
  77.  * displays the count value on the parent form.
  78. */
  79.  
  80.     public @CLASSNAME@(Form1 parent, int threadNumber)
  81.     //********************************
  82.     {
  83.         _parent = parent;
  84.         _threadNumber = threadNumber;
  85.     }
  86.  
  87. @end-code;
  88.  
  89. @begin-code Code "CounterThread::Prototype for CounterThread(threads2 parent)"
  90.  
  91.     public:
  92.         @@CLASSNAME@(threads2 parent);
  93.  
  94. @end-code;
  95.  
  96. @begin-code Code "CounterThread::run()"
  97.  
  98.     public void run()
  99.     //********************************
  100.     {
  101.         while (true) 
  102.         {
  103.             _counter = _counter + 1;
  104.             if (_counter > 1000)
  105.                 _counter = 0;
  106.             synchronized (this)
  107.             {
  108.                 _parent.setCounter(_threadNumber, _counter);
  109.             }
  110.         }        
  111.  
  112.     }
  113.  
  114. @end-code;
  115.  
  116. @begin-code Code "CounterThread::Prototype for run()"
  117.  
  118.     public:
  119.         void run();
  120.  
  121. @end-code;
  122. @end;
  123.