src/share/vm/runtime/thread.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 684 
 685   virtual WorkerThread* as_Worker_thread() const {
 686     assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
 687     return (WorkerThread*) this;
 688   }
 689 
 690   void set_id(uint work_id)             { _id = work_id; }
 691   uint id() const                       { return _id; }
 692 };
 693 
 694 // A single WatcherThread is used for simulating timer interrupts.
 695 class WatcherThread: public Thread {
 696   friend class VMStructs;
 697  public:
 698   virtual void run();
 699 
 700  private:
 701   static WatcherThread* _watcher_thread;
 702 
 703   static bool _startable;
 704   volatile static bool _should_terminate; // updated without holding lock

 705 
 706   os::WatcherThreadCrashProtection* _crash_protection;
 707  public:
 708   enum SomeConstants {
 709     delay_interval = 10                          // interrupt delay in milliseconds
 710   };
 711 
 712   // Constructor
 713   WatcherThread();
 714 
 715   // Tester
 716   bool is_Watcher_thread() const                 { return true; }
 717 
 718   // Printing
 719   char* name() const { return (char*)"VM Periodic Task Thread"; }
 720   void print_on(outputStream* st) const;
 721   void unpark();
 722 
 723   // Returns the single instance of WatcherThread
 724   static WatcherThread* watcher_thread()         { return _watcher_thread; }


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 684 
 685   virtual WorkerThread* as_Worker_thread() const {
 686     assert(is_Worker_thread(), "Dubious cast to WorkerThread*?");
 687     return (WorkerThread*) this;
 688   }
 689 
 690   void set_id(uint work_id)             { _id = work_id; }
 691   uint id() const                       { return _id; }
 692 };
 693 
 694 // A single WatcherThread is used for simulating timer interrupts.
 695 class WatcherThread: public Thread {
 696   friend class VMStructs;
 697  public:
 698   virtual void run();
 699 
 700  private:
 701   static WatcherThread* _watcher_thread;
 702 
 703   static bool _startable;
 704   // volatile due to at least one lock-free read
 705   volatile static bool _should_terminate;
 706 
 707   os::WatcherThreadCrashProtection* _crash_protection;
 708  public:
 709   enum SomeConstants {
 710     delay_interval = 10                          // interrupt delay in milliseconds
 711   };
 712 
 713   // Constructor
 714   WatcherThread();
 715 
 716   // Tester
 717   bool is_Watcher_thread() const                 { return true; }
 718 
 719   // Printing
 720   char* name() const { return (char*)"VM Periodic Task Thread"; }
 721   void print_on(outputStream* st) const;
 722   void unpark();
 723 
 724   // Returns the single instance of WatcherThread
 725   static WatcherThread* watcher_thread()         { return _watcher_thread; }