Results 1 to 3 of 3
  1. #1
    rajan701v is offline Member
    Join Date
    Jun 2011
    Posts
    9
    Rep Power
    0

    Default How to use two threads

    Hi , All...
    I am new to thread programming... well i want to know what is the best suitable way to use two threads pausing the one in between...

    That is,.. I have a one main Thread .. and i have another thread Thread_2.
    What i want is to run Thread_2 and pausing the main thread since the thread_2 not completes it's work.. and then main thread runs its and do its task..

    Please help..

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,015
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by rajan701v View Post
    That is,.. I have a one main Thread .. and i have another thread Thread_2.
    What i want is to run Thread_2 and pausing the main thread since the thread_2 not completes it's work.. and then main thread runs its and do its task..
    Your main thread can join() the other thread; read the API documentation for the Thread class for details.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    jagadeeshbabu is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Default

    you can use 2 threads useing 1st thread will start another thread will run
    like client and server application in : client is sending a request to server at the same time server is responding to u.
    thread1.start();
    thread2.start();

Similar Threads

  1. threads
    By brindha1688 in forum New To Java
    Replies: 3
    Last Post: 05-24-2011, 08:07 PM
  2. The right way of using threads
    By N00Bie in forum New To Java
    Replies: 9
    Last Post: 02-20-2011, 04:39 PM
  3. Threads
    By nsr2008.mca in forum New To Java
    Replies: 7
    Last Post: 10-18-2010, 11:47 AM
  4. Threads!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-04-2008, 04:11 PM
  5. Using threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 10:25 AM

Posting Permissions

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