< prev index next >

src/share/vm/gc/shared/concurrentGCThread.cpp

Print this page




  65 }
  66 
  67 void ConcurrentGCThread::terminate() {
  68   assert(_should_terminate, "Should only be called on terminate request.");
  69   // Signal that it is terminated
  70   {
  71     MutexLockerEx mu(Terminator_lock,
  72                      Mutex::_no_safepoint_check_flag);
  73     _has_terminated = true;
  74     Terminator_lock->notify();
  75   }
  76 }
  77 
  78 void ConcurrentGCThread::run() {
  79   initialize_in_thread();
  80   wait_for_universe_init();
  81 
  82   run_service();
  83 
  84   terminate();






  85 }
  86 
  87 void ConcurrentGCThread::stop() {
  88   // it is ok to take late safepoints here, if needed
  89   {
  90     MutexLockerEx mu(Terminator_lock);
  91     assert(!_has_terminated,   "stop should only be called once");
  92     assert(!_should_terminate, "stop should only be called once");
  93     _should_terminate = true;
  94   }
  95 
  96   stop_service();
  97 
  98   {
  99     MutexLockerEx mu(Terminator_lock);
 100     while (!_has_terminated) {
 101       Terminator_lock->wait();
 102     }
 103   }
 104 }


  65 }
  66 
  67 void ConcurrentGCThread::terminate() {
  68   assert(_should_terminate, "Should only be called on terminate request.");
  69   // Signal that it is terminated
  70   {
  71     MutexLockerEx mu(Terminator_lock,
  72                      Mutex::_no_safepoint_check_flag);
  73     _has_terminated = true;
  74     Terminator_lock->notify();
  75   }
  76 }
  77 
  78 void ConcurrentGCThread::run() {
  79   initialize_in_thread();
  80   wait_for_universe_init();
  81 
  82   run_service();
  83 
  84   terminate();
  85 
  86   // Can't "delete this" before we terminate as other code
  87   // holds references to 'this', but we must do some cleanup 
  88   // ourselves before allowing the native thread to terminate
  89 
  90   ThreadLocalStorage::set_thread(NULL);
  91 }
  92 
  93 void ConcurrentGCThread::stop() {
  94   // it is ok to take late safepoints here, if needed
  95   {
  96     MutexLockerEx mu(Terminator_lock);
  97     assert(!_has_terminated,   "stop should only be called once");
  98     assert(!_should_terminate, "stop should only be called once");
  99     _should_terminate = true;
 100   }
 101 
 102   stop_service();
 103 
 104   {
 105     MutexLockerEx mu(Terminator_lock);
 106     while (!_has_terminated) {
 107       Terminator_lock->wait();
 108     }
 109   }
 110 }
< prev index next >