File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How a thread can wait on itself? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How a thread can wait on itself?" Watch "How a thread can wait on itself?" New topic

How a thread can wait on itself?

Maduranga Liyanage
Ranch Hand

Joined: May 25, 2005
Posts: 124

I'm not sure how this can be done.

This is what I want to do:

What I want to do is for the main to read the user input value 'after' the user has actully input it. But when I do T.start(), it starts the thread and then immediately reads the value before user inputs it.

I want some way to wait till the user inputs it. So I did join() in main method, and I wait() in run() method and finally when the user is finished input it notify() so the main method will the value 'after' the user has input it.

But this doesn;t seem to work.
I even tried 'this' instead of 'T' but with no luck.

Thank you.
I agree. Here's the link:
subject: How a thread can wait on itself?
It's not a secret anymore!