• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

threads

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see this code

here the o/p is expected to be 0 followed 5000or more
but i get only 0 --- why

[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ September 17, 2003: Message edited by: Jessica Sant ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depending on your operating system (coughWindowscough) output from System.out.print() called right before a program exits may not appear on the console. Either use println() for the second call, or call System.out.flush() after the second print(). Otherwise, your code should work as expected.
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I complied and ran this code but replaced the line
wait(5000) with
wait()
The program didn't stop executing. My question is : Is notify/notifyAll the only way for the thread to stop waiting?
Thanks,
Lalitha
 
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Lalitha,
Only other method I can think of is interrup()
 
Lalitha Chandran
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Barkat...
Could you please refer to some resources for threads. I don't feel very comfortable with them.
Thank you,
Lalitha
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would start with thread tutorial at sun site. Follow that up with any books that you are reading. K & B is good but very limited for threads. I also read Ivor Horton's Begining Java 2 and some other books. Refer to JSL and API as much as possible.
Biggest help is practice.
Barkat
 
Lalitha Chandran
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you ....
Lalitha
 
Lalitha Chandran
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you ....
Lalitha
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic