[java] thread usage monitor
I am developing a multi-threaded game server. I would like to be able to monitor the amount of time that the server is idle.
Anyone have any ideas on a good way of implementing this without noticeably affecting the performance of the server?
Hitman
i don''t know if i can help any but,
couldn''t you check how many users are on the server every 5 minutes (or so). then, if there is no-one on the server get the system time. if the player check says that there are some players on the server, then get the system time again and subtract the later time from the first time. it would only be accurate to 4 minutes in 59 seconds, but not that it is that necessary (or is it?)
couldn''t you check how many users are on the server every 5 minutes (or so). then, if there is no-one on the server get the system time. if the player check says that there are some players on the server, then get the system time again and subtract the later time from the first time. it would only be accurate to 4 minutes in 59 seconds, but not that it is that necessary (or is it?)
I guess I should have been a little more clear. This is not going to be a connection oriented server. it will be mor like a web server (at least in the way it handles connections. A client will make a connection, the server will start a thread, process the request, then the connection will be dropped. All of this will only take milliseconds. What I want to know is how much of the servers time is sitting idle, and how m uch is taken up by these different threads. The only way I can figure to do this is to make an OS call, but of course then I lose my platform independence. Can anyone think of a purely java way of doing this?
Hitman
Hitman
If you use a resource pool for your threads it should be easy to have a class that reports on the usage of threads. Everytime a thread is requested, mark it with a current time, then check it on its return.
quote: Original post by Jim_Ross
If you use a resource pool for your threads it should be easy to have a class that reports on the usage of threads. Everytime a thread is requested, mark it with a current time, then check it on its return.
Hmmm....now why didn''t I think of that. I already have a resource pool to save having to new a thread everytime you need one. It should be straight forward to modify the checkin/checkout method to also keep track of time.
Thanks again,
Hitman
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement