About thread...

M

Mabel

HI,

Just want to know if I know the name of a thread
(say, ABC), is it possible to get connected to that
thread, and how?

I'm trying to use Socket but have no luck.
THx.
 
S

Soeren Degn Jahns

Just want to know if I know the name of a thread
(say, ABC), is it possible to get connected to that
thread, and how?

Assuming it's a Java Thread you can use the getName() method from the Thread
class.

If your class, in which you want to know the name of the current thread, is
not deriving from Thread itself you could obtain the name of the current
thread by:

Thread.currentThread().getName()

I'm trying to use Socket but have no luck.

I don't see how that would help you here :)
 
M

Mabel

Soeren Degn Jahns said:
Assuming it's a Java Thread you can use the getName() method from the Thread
class.

If your class, in which you want to know the name of the current thread, is
not deriving from Thread itself you could obtain the name of the current
thread by:

Thread.currentThread().getName()



I don't see how that would help you here :)

Thanks for the reply.
What I would like to do is to run a separate thread.
This thread will test if someone has log in (say, thread ABC).
If yes, and try to connect to it.

So in my program, I know the thread's name (in my case, ABC).
Then I would try to connect to it using Socket.

Is this possible?
 
S

Soeren Degn Jahns

Thanks for the reply.
What I would like to do is to run a separate thread.
This thread will test if someone has log in (say, thread ABC).
If yes, and try to connect to it.

What is it that you want to obtain by connecting to it? When it's just a
thread in your application, it seems a bit overkill to connect with a
socket. Depending on what you want to do a singleton is your friend.

So in my program, I know the thread's name (in my case, ABC).
Then I would try to connect to it using Socket.

As I wrote, I think a socket is a bit overkill. What is your app. supposed
to do / how should it work and what operations du you want your threads to
support?

Is this possible?

Probably, but enlighten me towards what you want to obtain, please :).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top