This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Mock Exam No.1 Marcus Green

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic