美文网首页
2018-06-16

2018-06-16

作者: yeathMe | 来源:发表于2018-06-16 23:41 被阅读0次
    
    // The first routine called by a new Java thread
    void JavaThread::run() {
      // initialize thread-local alloc buffer related fields
      this->initialize_tlab();
    
      // used to test validitity of stack trace backs
      this->record_base_of_stack_pointer();
    
      // Record real stack base and size.
      this->record_stack_base_and_size();
    
      // Initialize thread local storage; set before calling MutexLocker
      this->initialize_thread_local_storage();
    
      this->create_stack_guard_pages();
    
      this->cache_global_variables();
    
      // Thread is now sufficient initialized to be handled by the safepoint code as being
      // in the VM. Change thread state from _thread_new to _thread_in_vm
      ThreadStateTransition::transition_and_fence(this, _thread_new, _thread_in_vm);
    
      assert(JavaThread::current() == this, "sanity check");
      assert(!Thread::current()->owns_locks(), "sanity check");
    
      DTRACE_THREAD_PROBE(start, this);
    
      // This operation might block. We call that after all safepoint checks for a new thread has
      // been completed.
      this->set_active_handles(JNIHandleBlock::allocate_block());
    
      if (JvmtiExport::should_post_thread_life()) {
        JvmtiExport::post_thread_start(this);
      }
    
      EventThreadStart event;
      if (event.should_commit()) {
         event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
         event.commit();
      }
    
      // We call another function to do the rest so we are sure that the stack addresses used
      // from there will be lower than the stack base just computed
      thread_main_inner();
    
      // Note, thread is no longer valid at this point!
    }
    
    
    
    

    相关文章

      网友评论

          本文标题:2018-06-16

          本文链接:https://www.haomeiwen.com/subject/sxdieftx.html