Results 1 to 2 of 2

Thread: How to check if threads still exist?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    4

    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

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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
  •  



Click Here to Expand Forum to Full Width