• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How a thread can wait on itself?

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic