File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Using Thread.interrupt() method , to finish mq.get(..) call, before stated time interval. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Using Thread.interrupt() method , to finish mq.get(..) call, before stated time interval." Watch "Using Thread.interrupt() method , to finish mq.get(..) call, before stated time interval." New topic
Author

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

rohit chavan
Ranch Hand

Joined: Oct 08, 2010
Posts: 131

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

Joined: Oct 08, 2010
Posts: 131

Found a better way to do this.
Used repeating time intervals, for breaking the total WAIT time.
And it did the trick.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Thread.interrupt() method , to finish mq.get(..) call, before stated time interval.
 
Similar Threads
How to stop a Thread
A self interrupting thread.
wait & notify
Another Thread Q from Dans study guide
Dan's Question