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:
12 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: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1