• Post Reply Bookmark Topic Watch Topic
  • New Topic

listen for events  RSS feed

Murad Iqbal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!
I am looking for a solution for my scenario.
1. There is a socket which is receiving some data, for example Objects.
2. I am running a separate thread which should sleep/hang for say 10 seconds when an object is received on the socket (which is running on a separate thread).
3. If an object is received before those 10 seconds are expired, the thread should then wake up and the count for 10 seconds sleep should start again, hence the thread sleeps for other 10 seconds. this again wakes up if a message is received in between those 10 seconds.. and the loop goes on.
Kindly advise how to go about this? Is the Timer provided by Swing appropriate over here or usage of Thread is better? It is basically a heart beat application in which a thread keeps sleeping for 10 seconds on and on if objects are received on the socket signifying that the connection is alive. If a message is not received in those 10 seconds, then it is obvious that the connection is down or the other party is having some problems. Kindly advise.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!