• 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

Mock Exam No.1 Marcus Green

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi *,
Question 19:
http://www.jchq.net/mockexams/exam1.htm
----
When I compile and run the code, it prints
just "vandeleur" and nothing else...
Will say, the run() will never be called.
I tested with JBuilder 5.0
cu
Chris
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run the program from command line, getting the same result as you. My jdk version is jdk1.3.1_01.
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The fact that it prints only "vandeleur" on your computer, my computer, computer and several others does not mean you can be certain that is what will always be output.
Threading is non-deterministic.
You cannot be certain where the thread execution has got to by the time the output is called. This is a very important issue with threading and not at all obvious.
[ February 25, 2003: Message edited by: Marcus Green ]
 
Chris Lenz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marcus,
in this case, perhaps it would be better to offer another possibility to answer?
Perhaps that�s possible that there is an ouput of only "vandeleur" ?
By the way, a very, very good Mock Exam!
by
Chris
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marcus:
Thanks for the explaination. I did an experiment, adding a print statement in run(). The result shows run() get excuted, but after the print statement in main().
So it looks like run() thread get excuted slower, at least in my case.
Thanks again for the good mock exam.
Best Regards,
Don Liu
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This does not appear to be errata so I will move it to the Java Programmer Certification forum.
 
Marcus Green
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good move Dan. This is a stinker of a topic and it it is worth taking a look at this question to get the gist of the issue. The people who set the questions love to hammer your understanding of threading.
Marcus
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic