Retrieves the global ID of the process that owns the thread.

        @type  dwThreadId: int
        @param dwThreadId: Thread global ID.

        @rtype:  int
        @return: Process global ID.

        @raise KeyError: The thread does not exist.
181116
def get_pid_from_tid(self, dwThreadId):
        
        try:

            # No good, because in XP and below it tries to get the PID
            # through the toolhelp API, and that's slow. We don't want
            # to scan for threads over and over for each call.
##            dwProcessId = Thread(dwThreadId).get_pid()

            # This API only exists in Windows 2003, Vista and above.
            try:
                hThread = win32.OpenThread(
                    win32.THREAD_QUERY_LIMITED_INFORMATION, False, dwThreadId)
            except WindowsError:
                e = sys.exc_info()[1]
                if e.winerror != win32.ERROR_ACCESS_DENIED:
                    raise
                hThread = win32.OpenThread(
                    win32.THREAD_QUERY_INFORMATION, False, dwThreadId)
            try:
                return win32.GetProcessIdOfThread(hThread)
            finally:
                hThread.close()

        # If all else fails, go through all processes in the snapshot
        # looking for the one that owns the thread we're looking for.
        # If the snapshot was empty the iteration should trigger an
        # automatic scan. Otherwise, it'll look for the thread in what
        # could possibly be an outdated snapshot.
        except Exception:
            for aProcess in self.iter_processes():
                if aProcess.has_thread(dwThreadId):
                    return aProcess.get_pid()

        # The thread wasn't found, so let's refresh the snapshot and retry.
        # Normally this shouldn't happen since this function is only useful
        # for the debugger, so the thread should already exist in the snapshot.
        self.scan_processes_and_threads()
        for aProcess in self.iter_processes():
            if aProcess.has_thread(dwThreadId):
                return aProcess.get_pid()

        # No luck! It appears to be the thread doesn't exist after all.
        msg = "Unknown thread ID %d" % dwThreadId
        raise KeyError(msg)
1139993
def getNetworkFragmentID(self):
        
        print '%s call getNetworkFragmentID' % self.port
        if not self.__isOpenThreadRunning():
            print 'OpenThread is not running'
            return None

        leaderData = []
        leaderData = self.__sendCommand('leaderdata')
        return int(leaderData[0].split()[2], 16)
501000
static public Thread getThread(final long id) {
        final Thread[] threads = getAllThreads();
        for (Thread thread : threads)
            if (thread.getId() == id)
                return thread;
        return null;
    }
676282
public static int pid() {
        int localPID = 0;
        try {
            String name = ManagementFactory.getRuntimeMXBean().getName();
            String[] nameSplit = name.split("@");
            if(nameSplit.length > 1) {
                localPID = Integer.parseInt(nameSplit[0]);
            }
            return localPID;
        } catch(Throwable t) {
            throw new UnsupportedOperationException("An error occurred while getting the PID: " + t.getMessage()) ;
        }
    }
181884
def _getThread(self, given_thread_id=None, given_thread_type=None):
        
        if given_thread_id is None:
            if self._default_thread_id is not None:
                return self._default_thread_id, self._default_thread_type
            else:
                raise ValueError("Thread ID is not set")
        else:
            return given_thread_id, given_thread_type
1304713
public static final String getThreadId() {
        String id = threadids.get();
        if (null == id) {
            // Pad the tid out to 8 characters
            id = getThreadId(Thread.currentThread());
            threadids.set(id);
        }
        return id;
    }
667562
def color_for_thread(thread_id):
    
    if thread_id not in seen_thread_colors:
        seen_thread_colors[thread_id] = next(thread_colors)

    return seen_thread_colors[thread_id]
833057
def instance_thread_global(name, value = nil)
      sc = class << self
        extend DSLKit::ThreadGlobal
        self
      end
      sc.thread_global name, value
      self
    end
1056699
def process_internal_commands(self):
        '''
        '''
        with self._main_lock:
            self.check_output_redirect()

            program_threads_alive = {}
            all_threads = threadingEnumerate()
            program_threads_dead = []
            with self._lock_running_thread_ids:
                reset_cache = not self._running_thread_ids

                for t in all_threads:
                    if getattr(t, 'is_pydev_daemon_thread', False):
                        pass  # I.e.: skip the DummyThreads created from pydev daemon threads
                    elif isinstance(t, PyDBDaemonThread):
                        pydev_log.error_once('Error in debugger: Found PyDBDaemonThread not marked with is_pydev_daemon_thread=True.')

                    elif is_thread_alive(t):
                        if reset_cache:
                            # Fix multiprocessing debug with breakpoints in both main and child processes
                            # (https://youtrack.jetbrains.com/issue/PY-17092) When the new process is created, the main
                            # thread in the new process already has the attribute 'pydevd_id', so the new thread doesn't
                            # get new id with its process number and the debugger loses access to both threads.
                            # Therefore we should update thread_id for every main thread in the new process.
                            clear_cached_thread_id(t)

                        thread_id = get_thread_id(t)
                        program_threads_alive[thread_id] = t

                        self.notify_thread_created(thread_id, t, use_lock=False)

                # Compute and notify about threads which are no longer alive.
                thread_ids = list(self._running_thread_ids.keys())
                for thread_id in thread_ids:
                    if thread_id not in program_threads_alive:
                        program_threads_dead.append(thread_id)

                for thread_id in program_threads_dead:
                    self.notify_thread_not_alive(thread_id, use_lock=False)

            # Without self._lock_running_thread_ids
            if len(program_threads_alive) == 0:
                self.finish_debugging_session()
                for t in all_threads:
                    if hasattr(t, 'do_kill_pydev_thread'):
                        t.do_kill_pydev_thread()
            else:
                # Actually process the commands now (make sure we don't have a lock for _lock_running_thread_ids
                # acquired at this point as it could lead to a deadlock if some command evaluated tried to
                # create a thread and wait for it -- which would try to notify about it getting that lock).
                curr_thread_id = get_current_thread_id(threadingCurrentThread())

                for thread_id in (curr_thread_id, '*'):
                    queue = self.get_internal_queue(thread_id)

                    # some commands must be processed by the thread itself... if that's the case,
                    # we will re-add the commands to the queue after executing.
                    cmds_to_add_back = []

                    try:
                        while True:
                            int_cmd = queue.get(False)

                            if not self.mpl_hooks_in_debug_console and isinstance(int_cmd, InternalConsoleExec):
                                # add import hooks for matplotlib patches if only debug console was started
                                try:
                                    self.init_matplotlib_in_debug_console()
                                    self.mpl_in_use = True
                                except:
                                    pydev_log.debug("Matplotlib support in debug console failed", traceback.format_exc())
                                self.mpl_hooks_in_debug_console = True

                            if int_cmd.can_be_executed_by(curr_thread_id):
                                pydev_log.verbose("processing internal command ", int_cmd)
                                int_cmd.do_it(self)
                            else:
                                pydev_log.verbose("NOT processing internal command ", int_cmd)
                                cmds_to_add_back.append(int_cmd)

                    except _queue.Empty:  # @UndefinedVariable
                        # this is how we exit
                        for int_cmd in cmds_to_add_back:
                            queue.put(int_cmd)
356723
def __get_pid_and_tid(self):
        ""
        self.dwThreadId, self.dwProcessId = \
                            win32.GetWindowThreadProcessId(self.get_handle())
575891
def get_pid(self):
        
        if self.dwProcessId is None:
            if self.__process is not None:
                # Infinite loop if self.__process is None
                self.dwProcessId = self.get_process().get_pid()
            else:
                try:
                    # I wish this had been implemented before Vista...
                    # XXX TODO find the real ntdll call under this api
                    hThread = self.get_handle(
                                        win32.THREAD_QUERY_LIMITED_INFORMATION)
                    self.dwProcessId = win32.GetProcessIdOfThread(hThread)
                except AttributeError:
                    # This method really sucks :P
                    self.dwProcessId = self.__get_pid_by_scanning()
        return self.dwProcessId
1374615
public static String getId(ClassLoader loader)
  {
    for (; loader != null; loader = loader.getParent()) {
      if (loader instanceof DynamicClassLoader) {
        String name = ((DynamicClassLoader) loader).getId();

        if (name != null)
          return name;
        else
          return "";
      }
    }

    return Thread.currentThread().getContextClassLoader().toString();
  }
316100
def get_thread(self, thread_key):
		'''
		'''
		uri = '/'.join([self.api_uri,
						self.threads_suffix,
						thread_key
						])
		return self._req('get', uri)
1041810
public int getIdleThreads()
   {
      if (executor instanceof ThreadPoolExecutor)
      {
         final ThreadPoolExecutor tpe = (ThreadPoolExecutor)executor;
         return tpe.getPoolSize() - tpe.getActiveCount();
      }
      return -1;
   }
848861
private int processId(final java.lang.Process process) {
    int processId = 0;
    try {
      final Field f = process.getClass().getDeclaredField("pid");
      f.setAccessible(true);

      processId = f.getInt(process);
    } catch (final Throwable e) {
      e.printStackTrace();
    }

    return processId;
  }
690100
public static long getThreadId() {
        final Long threadId = THREAD_LOCAL.get();
        if (threadId != null) {
            return threadId;
        }
        return Thread.currentThread().getId();
    }
843950
def thread_exists(self, thread_id):
        
        return self._requests_session.head(
            self._url.thread_api_url(
                thread_id=thread_id
                )
        ).ok