• Post Reply Bookmark Topic Watch Topic
  • New Topic

forcing hotspot server VM  RSS feed

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Effective Java 2nd edition, item 66 "Synchronize Access to Shared mutable data" it states the following program can run forever:



but on my windows and mac machines (windows, mac), it runs as expected, stopping after a second.
on a ubuntu development server, it hangs like the author says it will.
The author says the virtual machine may transform this:


into this:


"which is precisely what the HotSpot Server VM does"


So, I thought that I could force the HotSpot server vm option with java -server StopThread, but I could not get the
program to run any differently.
my windows desktop:


server:


Question is: How to force the HotSpot server to make my program run forever on my Windows desktop?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is unlikely you could force the JVM do to this.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After more testing, it turns out that StopThread does run forever (on my desktop) if I use java -server StopThread and it stops after 1 second when I use java StopThread
and on the server it does run forever if I use java StopThread.
I think the takeaway here is that, like the author says, you can't rely on it running forever or NOT running forever.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right; it's implementation-dependent.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!