Results 1 to 6 of 6
  1. #1
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    5

    Default Several Questions on Thread

    I'm not getting join() method.
    t.join() waits for the thread t to die.
    So it's waiting for itself to die? Why?
    What does it mean for a thread to "die?"
    What happens after it dies?
    What happens if it doesn't die?
    sleep() method pauses the current thread for a specific time. Isn't that what join() is doing? What's the difference between them?
    is join(0) the same as join() ?

    It be appreciated if anyone could answer those questions.
    Last edited by Lil_Aziz1; 01-04-2010 at 03:33 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Do read the tutorials from the start. When discussing the join method we are dealing with two threads. Join causes the curently executing thread (the one that executed the t.join statement) to pause until the thread t has completed.
    The sleep method on the other hand acts on one thread(the currently executing one). That's why it's static while join is not.
    Reading the API specs and the tutorials is a must for understanding those things.

  3. #3
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    5

    Default

    API specs?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  5. #5
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    5

    Default

    Oh right. Just didn't know what it was called.

  6. #6
    dksingh28 is offline Member
    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Cool thread

    t.join() is similar to
    wait the main thread till the thread t finishes its work. After finishing a thread comes in terminated state and we call it died.

Similar Threads

  1. Couple of questions regarding threading
    By exernet in forum New To Java
    Replies: 1
    Last Post: 12-15-2009, 12:23 PM
  2. Thread questions
    By McChill in forum New To Java
    Replies: 2
    Last Post: 03-17-2009, 06:48 AM
  3. Couple of newbie questions
    By ananasman in forum New To Java
    Replies: 11
    Last Post: 11-20-2008, 11:54 PM
  4. Replies: 9
    Last Post: 10-18-2008, 04:31 PM
  5. Couple of Problems
    By joz_12345 in forum Java 2D
    Replies: 2
    Last Post: 03-06-2008, 04:13 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •