Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:47:08+00:00 2026-05-28T01:47:08+00:00

Both of wait() and join() methods when called by thread-1 on thread-2 makes thread-1

  • 0

Both of wait() and join() methods when called by thread-1 on thread-2 makes thread-1 wait for the thread-2, either for sometime or till thread-2 completes.

If we are using the overloaded versions of these methods i.e. wait(long timeout) and join(long millis), then

  1. In case of wait(long timeout), thread-1 will become runnable either by notify (or notifyall) or even timeout occurs (whichever is first).

  2. In case of join(long millis), thread-2 will become runnable either when thread-2 completes or timeout occurs (whichever is first).

So then what is the difference between these two implementations?

Some that I thought are these :-

  1. For wait(), we need to have the lock on the object we are waiting on. For join() these are not necessary.
  2. After executing wait(), the thread removes lock it obtained and re-gains the lock once it becomes running again. But what about join? Does a thread removes a lock after executing join if this was executed from a synchronized block (or method)?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:47:09+00:00Added an answer on May 28, 2026 at 1:47 am

    As you say, the "release" process is quite different – in one case (wait) it’s based on notify(), the other (join) it’s based on the thread completing. They’re entirely different calls which serve entirely different purposes.

    In fact, there are explicit warnings not to call wait() on Thread monitors (although I can’t immediately find those warnings), as internal Java code acquires the locks for them (and uses wait/notify itself).

    But no, calling join() on Thread doesn’t release the monitor if the currently executing thread owns it.

    Basically, you shouldn’t think of them as similar at all – one is for waiting for a thread to terminate; the other is for waiting for co-operative coordination.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Both Thread.Sleep(timeout) and resetEvent.Wait(timeout) cause execution to pause for at least timeout milliseconds, so
How do I calculate network utilization for both transmit and receive either using C
Assuming that both of these approaches load the script properly, and that I wait
Both of these appservers are at least in part OSGI based. One (Glassfish) is
Both: CLSID IID Having specified the above, and using: CoCreateInstance() To returning a single
So I'm trying to create a signal handler using pthreads which works on both
In particular, I'm looking at using TPL to start (and wait for) external processes.
I frequently need to have a thread wait for the result of another thread.
I have experimented with both of these loops and came to notice that even
I want to use a thread pool to both initiate/cancel overlapped read operations --

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.