home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 September / dppcpro0998.iso / Rwc / Sybase / Install.exe / samples.z / CounterThread.wxc < prev    next >
Encoding:
Text File  |  1998-03-25  |  2.3 KB  |  114 lines

  1. Save Format v2.3(19971110)
  2. @begin ClassFile "CounterThread"
  3.  
  4.  @begin Object "Powersoft Java AWT 1.02::powersoft.painter.Class"
  5.   DesignName CounterThread;
  6.   @begin ClassProperties
  7.    Exported 1;
  8. @begin-code BaseClassList
  9.  
  10. extends Thread
  11.  
  12. @end-code;
  13.    @begin CPMethod "CounterThread"
  14.     @begin CPPrototype "Prototype for CounterThreadMethod"
  15. @begin-code SourceCode "Prototype for CounterThreadMethod"
  16.  
  17.         // Not used for Java classes
  18.  
  19. @end-code;
  20.     @end;
  21.     @begin CPDefinition "CounterThreadMethod"
  22. @begin-code SourceCode "CounterThreadMethod"
  23.  
  24.     //
  25.     // CounterThreadMethod
  26.     //
  27.  
  28.     public CounterThread(Form_Threads parent, int threadNumber)
  29.     {
  30.         //  constructor for CounterThread class
  31.         _parent = parent;
  32.         _threadNumber = threadNumber;
  33.     }
  34.  
  35. @end-code;
  36.     @end;
  37.    @end;
  38.    @begin CPMethod "run"
  39.     @begin CPPrototype "Prototype for runMethod"
  40. @begin-code SourceCode "Prototype for runMethod"
  41.  
  42.         // Not used for Java classes
  43.  
  44. @end-code;
  45.     @end;
  46.     @begin CPDefinition "runMethod"
  47. @begin-code SourceCode "runMethod"
  48.  
  49.     //
  50.     // runMethod
  51.     //
  52.  
  53.     public void run()
  54.     {
  55.         //  run method for thread
  56.         while (true)
  57.         {
  58.             _counter = _counter + 1;
  59.             if (_counter > 1000)
  60.                 _counter = 0;
  61.             synchronized (this)
  62.             {
  63.                 _parent.updateCounter(_threadNumber, _counter);
  64.             }
  65.         }
  66.  
  67.     }
  68.  
  69. @end-code;
  70.     @end;
  71.    @end;
  72.   @end;
  73.   @begin CodeBlocks
  74.    @begin CodeBlock "HppPrefix"
  75.     FunctionScope 1;
  76. @begin-code SourceCode "Imports()"
  77.  
  78. // add your custom import statements here
  79.  
  80.  
  81. //  This class constructs the counting threads.
  82. //  Each thread counts to 1000 and then resets to 0.
  83.  
  84. @end-code;
  85.    @end;
  86.    @begin CodeBlock "ClassContents"
  87.     FunctionScope 1;
  88. @begin-code SourceCode "Data Members()"
  89.  
  90.     // add your data members here
  91.     private Form_Threads _parent;
  92.     private int _threadNumber;
  93.     private int _counter = 0;
  94.  
  95. @end-code;
  96.    @end;
  97.    @begin CodeBlock "GeneratedClassContents"
  98.     FunctionScope 1;
  99. @begin-code SourceCode "GeneratedClassContents()"
  100.  
  101.  
  102. @end-code;
  103.    @end;
  104.    @begin CodeBlock "CppPrefix"
  105.     FunctionScope 1;
  106. @begin-code SourceCode "()"
  107.  
  108.  
  109. @end-code;
  110.    @end;
  111.   @end;
  112.  @end;
  113. @end;
  114.