wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads 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 "threads" Watch "threads" New topic
Author

threads

Mona Gadkari
Ranch Hand

Joined: Jul 28, 2003
Posts: 64
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 ]

Mona(Varijasmom)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Lalitha Chandran
Ranch Hand

Joined: Jul 03, 2003
Posts: 92
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
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Hello Lalitha,
Only other method I can think of is interrup()
Lalitha Chandran
Ranch Hand

Joined: Jul 03, 2003
Posts: 92
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

Joined: Aug 05, 2002
Posts: 787
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

Joined: Jul 03, 2003
Posts: 92
Thank you ....
Lalitha
Lalitha Chandran
Ranch Hand

Joined: Jul 03, 2003
Posts: 92
Thank you ....
Lalitha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: threads