Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Design Issue  RSS feed

 
Amer Seifeddine
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am proceeding in building my thread design and I am facing one issue with interrupting the working thread. There are two threads:

1- UI and listening to stop the working thread.
2- Working thread with many tasks in sequence.

I am passing the state flag to the working thread from the ui and working thread is checking the state from time to time. However, i have realized that cleaning up tasks is not enough since tasks will continue processing unless u check for intrerruption after every action!!!

How can I achieve this interruption and force all tasks and current thread to give up and stop? Did you do this before?

Thanks folks.
 
Amer Seifeddine
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is the best idea to Throw a custom exception?
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem is not clear from the post.

What cleanup operation you want and why you want to interrupt your thread?
[ July 02, 2006: Message edited by: Naseem Khan ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, i have realized that cleaning up tasks is not enough since tasks will continue processing unless u check for intrerruption after every action!!!


Why is checking like that not good? This seems pretty sensible

Are you using an Executor to execute your tasks? Look into that API for how to stop the thread pool.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!