Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Problem in Multithreading ,,....

Problem in Multithreading ,,....

Scheduled Pinned Locked Moved Java
help
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gateway23
    wrote on last edited by
    #1

    sir/mam i need to know the working of join() .... i tried books and net but i didn't got it. Please tell me exactly why we use join() function and what happens when we call the join().. Thanks

    T D A 3 Replies Last reply
    0
    • G gateway23

      sir/mam i need to know the working of join() .... i tried books and net but i didn't got it. Please tell me exactly why we use join() function and what happens when we call the join().. Thanks

      T Offline
      T Offline
      TorstenH
      wrote on last edited by
      #2

      is google down again? http://www.java-samples.com/showtutorial.php?tutorialid=301[^] can't explain it better.

      regards Torsten I never finish anyth...

      D 1 Reply Last reply
      0
      • G gateway23

        sir/mam i need to know the working of join() .... i tried books and net but i didn't got it. Please tell me exactly why we use join() function and what happens when we call the join().. Thanks

        D Offline
        D Offline
        David Skelly
        wrote on last edited by
        #3

        To be fair, the javadoc for this method isn't very clear:

        Waits for this thread to die.

        That's it. Not the most helpful javadoc I've ever seen. The Oracle Java tutorial[^] is better:

        The join method allows one thread to wait for the completion of another. If t is a Thread object whose thread is currently executing,

        t.join();

        causes the current thread to pause execution until t's thread terminates.

        I think that's quite clear and succinct.

        G 1 Reply Last reply
        0
        • T TorstenH

          is google down again? http://www.java-samples.com/showtutorial.php?tutorialid=301[^] can't explain it better.

          regards Torsten I never finish anyth...

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          I tried to follow this link and got a security warning that the website was trying to open a program on my computer. No idea what it was or why, but that sort of thing makes me nervous.

          T 1 Reply Last reply
          0
          • D David Skelly

            I tried to follow this link and got a security warning that the website was trying to open a program on my computer. No idea what it was or why, but that sort of thing makes me nervous.

            T Offline
            T Offline
            TorstenH
            wrote on last edited by
            #5

            :confused: no thread here.

            regards Torsten I never finish anyth...

            1 Reply Last reply
            0
            • D David Skelly

              To be fair, the javadoc for this method isn't very clear:

              Waits for this thread to die.

              That's it. Not the most helpful javadoc I've ever seen. The Oracle Java tutorial[^] is better:

              The join method allows one thread to wait for the completion of another. If t is a Thread object whose thread is currently executing,

              t.join();

              causes the current thread to pause execution until t's thread terminates.

              I think that's quite clear and succinct.

              G Offline
              G Offline
              gateway23
              wrote on last edited by
              #6

              thanks david..it helps alot. :)

              1 Reply Last reply
              0
              • G gateway23

                sir/mam i need to know the working of join() .... i tried books and net but i didn't got it. Please tell me exactly why we use join() function and what happens when we call the join().. Thanks

                A Offline
                A Offline
                Ashish Tyagi 40
                wrote on last edited by
                #7

                To ensure that a thread (referenced by some reference say threadRef) is finished, then you join() on that reference. like threadRef.join() if that thread is finished, then join() returned immediately otherwise join() will blocked until that thread get finished. For example if you create three thread (a, b, c) for doing three different task A, B, C, from your main thread, but you need some initialization processing (which must be executed before start-up of a, b, c) and shutdown processing (which must be executed after finishing of a, b, c) then you may code like this // in main() System.out.println("System started"); initialization(); // a, b, c are not running yet. System.out.println("initialization complete "); Thread a = new Thread(new Task_A_RunnableClass()); Thread b = new Thread(new Task_B_RunnableClass()); Thread c = new Thread(new Task_C_RunnableClass()); a.start(); System.out.println("Thread "a" started "); b.start(); System.out.println("Thread "b" started "); c.start(); System.out.println("Thread "c" started "); //Now wait for all thread to finished. a.join(); System.out.println("Thread "a" finiished "); b.join(); System.out.println("Thread "b" finiished "); c.join(); System.out.println("Thread "c" finiished "); shutdown(); // a, b, c are finished now. System.out.println("System shutdown..... ");

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups