wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Thread Expiry issue. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread Expiry issue." Watch "Thread Expiry issue." New topic
Author

Thread Expiry issue.

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Hi guys,

I need some guidance on threads.

What I want to do, is start a thread, and ask it to complete some operation - if the operation (stuff in my public void run() method) is complete within the timel limit proceed, if however it's still running, then I want to terminate the operation and diplay error such as "time out...."

What I need is a thread expiry method,

I have the code below, how do I go about imnplementing what I want to do?



I think Thread.join(2000) maybe useful - am I on the right track,

Can someone point me to the right example.

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

A timed join, combined with a status flag (boolean?) would be good:
Please note the volatile keyword; it's quite necessary unless you want to use synchronization.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Expiry issue.