[concurrency-interest] ThreadPoolExecutor.afterExecute(Runnable r, Throwable t) is not behaving as per documentation

Jagadheeswar Reddy reddyj at gmail.com
Wed May 3 22:34:35 EDT 2006

Hi ,
I have created a runnable task and deliberately created an unchecked
exception in my run method.
My class TaskExecutor extends  ThreadPoolExecutor  and overrides
afterExecute method .
When I check for Throwable object in this method, it is still null,
inspite of throwing unchecked exception in run method
My code:
public class TaskExecutor extends ThreadPoolExecutor {
            public TaskExecutor() {
                        super(2, 2, 10, TimeUnit.SECONDS, new
            public boolean scheduleTask(Runnable r) {
                                    Future<Object> resultFetcher;
                                    Object result = "hello runnable
executed successfully";
                                    resultFetcher =submit(r, result);
                                    return true;
            protected void afterExecute(Runnable r,Throwable t){
                                    System.out.println("inside the
method afterExecute");
System.out.println("Exception is thrown in Runnable method");
                        }catch(Exception e){
My runnable task run method throws NullPointerException :
  public void  run(){
             Object out=null;
            System.out.println("inside the runnable task
Please let me know if iam doing something wrong
Thanks& Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060503/897dc686/attachment.html

More information about the Concurrency-interest mailing list