Win a copy of Murach's Python Programming this week in the Jython/Python forum!
    Bookmark Topic Watch Topic
  • New Topic

ExecutorService with Timeout feature which will stop the task after specified time  RSS feed

 
Kousik Majumder
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,

We do have a logging feature in our application which is invoked as part of New thread. This logging post messages in MQ, if MQ is down without writing the logs the LoggerThread objects are accumulating in server insisting server to hang. The problem is we are using ExecutorService as a thread pool and writing in logs using this.

What I am looking for now is incorporating Timeout into this ExecutorService which will cancel/stop/kill the LoggerThread thread from executing after a specified timeout period.

Can someone give a solution using an example.
 
Henry Wong
author
Sheriff
Posts: 22832
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator

This is somewhat related to your other topic, so I will link it here...

http://www.coderanch.com/t/641490/java/java/stop-loop-timeout-feature


However, it is not really a duplicate -- as you still need some way for the threads to work with MQ in a cooperative manner. I will keep this thread open for that discussion, and if it does happen, I will also add the correct forum (as it is no longer thread related) for you.

Henry
 
Henry Wong
author
Sheriff
Posts: 22832
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator

Looks like the conversation is happening in the other thread. So, let's lock this one.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!