• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

forcing hotspot server VM

 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • 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?
 
Author
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 VI Editor Tomcat Server
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right; it's implementation-dependent.
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic