def get_thread_id():
    """
    Returns a unique ID for each thread in the range 0 (inclusive)
    to :func:`~.get_num_threads` (exclusive).
    """
    # Called from the interpreter directly, this should return 0
    # Called from a sequential JIT region, this should return 0
    # Called from a parallel JIT region, this should return 0..N
    # Called from objmode in a parallel JIT region, this should return 0..N
    _launch_threads()
    return _get_thread_id()

    Returns a unique ID for each thread in the range 0 (inclusive)
    to :func:`~.get_num_threads` (exclusive).
    
numba/np/ufunc/parallel.py