• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Design Issue

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is the best idea to Throw a custom exception?
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic