File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread Expiry issue." Watch "Thread Expiry issue." New topic

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.

Rob Spoor

Joined: Oct 27, 2005
Posts: 19783

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Thread Expiry issue.