Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to count number of times thread executed

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to count number of times thread executed

    in a thread pool, how to a thread determine number of times it executed and put return pool.

    (Sorry about my english skill.)


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: How to count number of times thread executed

    I'm a little confused as to what you want. Are you trying to determine how many items a certain thread in a thread pool executed tasks? Or are you trying to determine how many items have been processed in total by that thread pool (which could contain multiple threads)?

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to count number of times thread executed

    For example:
    Thread pool contain 3 threads: t1,t2,t3.
    when finished: t1 executed 3 times.
    t2 executed 2 times.
    t3 executed 2 times.
    how to count number of times each thread executed?

  4. #4
    Junior Member
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to count number of times thread executed

    If you are using the ThreadPoolExecuter

    then simply override the :beforeExecute and afterExecute Method

Similar Threads

  1. Java Dos Logic Test count all non increasing number
    By Jhovarie in forum Object Oriented Programming
    Replies: 3
    Last Post: January 13th, 2011, 02:28 PM
  2. tick tack toe hard times!!
    By JpJ in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 12th, 2010, 07:15 AM
  3. Counting How Many Times Program Was Excecuted
    By Override in forum Loops & Control Statements
    Replies: 2
    Last Post: October 30th, 2010, 05:11 PM
  4. Replies: 1
    Last Post: October 16th, 2010, 03:32 PM
  5. GuessWhat- same errors repeated 4 times?
    By iank in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 5th, 2009, 07:32 PM