views:

78

answers:

3

Hi,

is there anything like an identifier of a NSSThread? The following code:

NSLog(@"thread: %@",(NSThread*)aThread);

results in something like this:

Thread: {name = (null), num = 6}

Is there a way to get this thread number, maybe?

Best, heinrich

+3  A: 

You can set the name of the thread using setName: on a NSThread.

Patrik Svensson
+4  A: 

Just use the address of the NSThread instance. There is only ever one instance representing a thread and that instance will live exactly as long as the thread. If a thread dies and a new thread is created, you may get a new instance at the same address, but the thread number may also be re-used, too.

bbum
A: 

I guess I will use a combination of object address and name. Maybe that works. Best, heinrich

Heinrich