15:46, EET
September 18, 2017
Hi,
I am using Java SDK 3.1.6. My server uses a timer to repeatedly trigger events in a separate thread. When the server shuts down there is always an exception when this thread is executed (“Exception in thread “Timer-0″ com.prosysopc.ua.server.UaInstantiationException: Could not get type node.”)
I want to stop the timer when the server is going to shut down. I assume it is not the best way to read a node’s value (e.g. ServerStatus) because the reading might fail.
Is there a good way to get notified when the server is going to shut down to stop my extra threads?
Luckily there are no damages when this exception occurs. But it looks awful if there is always an exception message on shutdown. And the return value of this process is always Bad (not 0/Success).
Thomas
15:53, EET
April 3, 2012
Hi,
Is there any reason you cannot simply stop the timer before you call UaServer.shutdown?
If not possible then I would need more details, e.g. is also the JVM shutting down or just a single server? If whole JVM, most applications have a somewhat central place to handle shutdown and they usually register a shutdownhook via Runtime.getRuntime().addShutdownHook (https://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html#addShutdownHook-java.lang.Thread-). It of course depends on what conditions and how the shutdown is triggered.
Most Users Ever Online: 1919
Currently Online:
24 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 730
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech KubalaModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1