Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Thread.interrupt() method , to finish mq.get(..) call, before stated time interval.

 
rohit chavan
Ranch Hand
Posts: 132
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I am trying to alter a piece of code which works with IBM MQ .

While invoking the get(...) method on the mq, we can provide wait interval , i.e. for how much time the thread will wait for a message to arrive in the queue.

When this time interval is too long , we want to stop this perticular thread , from waiting on mq.get(..) method (in some user initiated stoppage)

(There is some other logic that comes after the mq.get(), and we just intend to interrupt the thread to end waiting on mq.get() call)

One of the probable solutions would be invoking Thread.interrupt(); on the thread which has been waiting for mq.get(..) to completed.

What I am trying to understand here is , if this is a proper approach and can this be achieved in a better way?

Your help would be very much helpful on this one.

Thank you,
Rohit
 
rohit chavan
Ranch Hand
Posts: 132
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found a better way to do this.
Used repeating time intervals, for breaking the total WAIT time.
And it did the trick.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic