Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why first output is second output  RSS feed

 
Jonas Dimsa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
im reading a tutorial and tried to run Safelock example shown in HERE
When i run this program the first output lines are :

Gaston: Alphonse has bowed back to me!
Gaston: Alphonse has bowed to me!

And i cant undestand how the first line can be "Gaston: Alphonse has bowed back to me", if the first output statement in method "bow" is "...bowed to me..." and both bowee and bower objects are locked for certain thread. so i thought if one thread started some method it has to do all statements in the order they are written and others threads cannot interleave because of locking both objects. so in my opinion the first lines of the output shoud be :

Gaston: Alphonse has bowed to me!
Gaston: Alphonse has bowed back to me!

or the same but with different names(first output should be" has bowed to me")

tell me if i understand the flow incorectly. it would be greate if you could explain the flow of execution, which leads to such situation(first output sentence is "bowed back to me")

p.s. more often the output is the same i expected. but sometimes i get result i can't understand.


thanks and sorry for my language mistakes
 
Jonas Dimsa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
srr for mistake, i expected the first lines of output shoud be:

Gaston: Alphonse has bowed to me!
Alphonse : Gaston has bowed back to me!

i mixed the order of the names in second line
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It certainly works that way for me; perhaps you, as a lucky Windows user, are stuck with a terminal that's not quite sure of its size, and is cutting off the first line? You might try running it and capturing the output in a file, then looking at the file in an editor:

java Safelock > output
 
Jonas Dimsa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you're absolutely right. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!