|
-
Mar 22nd, 2008, 01:03 PM
#1
Thread Starter
New Member
How to check if threads still exist?
Hi.
I'm making a chatprogram, and the server creates a thread for each client connected. The server stores these threads in a vector. But how can I remove the thread out of the vector when the thread doesn't exists anymore (when the client has disconnected)?. I know the removeElement function, but how can I check whether the thread exists or not?
Thanks,
Niek
-
Mar 23rd, 2008, 01:24 AM
#2
Re: How to check if threads still exist?
Weird approach. Well, if you want to check if the Thread is running use "Thread.isAlive()", to check if it exists at all just make sure it's not null, unless you're calling the .destroy method to terminate the thread then use "Thread.getState() == Thread.State.TERMINATED"
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|