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 Android Security Essentials Live Lessons this week in the Android 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: 19656

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
Consider Paul's rocket mass heater.
subject: Thread Expiry issue.
Similar Threads
Getting Straight Thread class and Runnable interface
Session Tracking in Wap
Basic invokeLater question
? What is the advantage of using Runnable interface instead of extending Thread class