I am creating multiple threads in my python program with thread name. Is there any way I can identify a specific task from /proc//task/*. I can see /proc/17094/task/17095/comm but that prints my program name only not the thread name
class myThread (threading.Thread):
def __init__(self, threadID, name, counter):
threading.Thread.__init__(self, name=name)
self.threadID = threadID
self.name = name
self.counter = counter
def run(self):
print "Starting " + self.name
# Get lock to synchronize threads
print_time(self.name, self.counter, 9)
# Free lock to release next thread
def print_time(threadName, delay, counter):
while counter:
time.sleep(delay+9)
print "%s: %s" % (threadName, time.ctime(time.time()))
threadLock.acquire()
counter -= 1
threadLock.release()
threadLock = threading.Lock()
threads = []
# Create new threads
thread1 = myThread(1, "Thread-1", 1)
thread2 = myThread(2, "Thread-2", 2)
# Start new Threads
thread1.start()
thread2.start()
# Add threads to thread list
threads.append(thread1)
threads.append(thread2)
print "Started both threads"
# Wait for all threads to complete
for t in threads:
t.join()
print "Exiting Main Thread"
Here I want to see the thread based on name - Thread-1 -
I can see the tasks under /proc/
~ # ps -ef | grep thread1
root 17787 4859 0 00:24 pts/0 00:00:00 /bin/python ./thread1.py
root 17800 4938 0 00:24 pts/1 00:00:00 grep thread1
~ # ls -l /proc/17787/task/
total 0
dr-xr-xr-x 7 root root 0 Jun 15 00:24 17787
dr-xr-xr-x 7 root root 0 Jun 15 00:24 17788
dr-xr-xr-x 7 root root 0 Jun 15 00:24 17789
But there I couldn't see Thread-1 in any files under these directories.