• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

ExecutorService and FutureTask - Blocked Thread

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the following code:



I'm running the aforementioned code inside a servlet container (tomcat).

The native method calls a Delphi method that executes a "showMessage", when the futureTask is running the native method calls the showMessage (it will just wait for the user to press "OK"), because it executes inside a servlet, the user doesn't see the dialog message, so, the task will run until the timeout.

The problem is that my task stops, but the thread (pool-1-thread-1) doesn't stop.

In that case, how can I kill a thread?

Thanks in advance.
 
Rancher
Posts: 5090
82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the thread is part of the thread pool in an ExecutorService, the best way is probably to call shutdown() on the ExecutorService.

Alternately, if you aren't yet ready to shut down the whole ExecutorService, you don't really need to stop the thread. It can just wait until the ExecutorService is given a new task that it can work on. Or until shutdown() is called.
 
Rafael F. Oliveira
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My native method is synchronized and "showMessage" is called in some cases...if the thread isn't stopped or killed new tasks will start in a blocked mode. Because that I would like to kill a specific thread instead of all of them when the timeout is exceeded. Is it possible?

I can get the thread by use the following code:


 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic