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 5 of 5

Thread: How to get Progress updates from multiple threads...

  1. #1
    Junior Member Becca's Avatar
    Join Date
    Nov 2011
    Posts
    8
    My Mood
    Sleepy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to get Progress updates from multiple threads...

    Sorry in advance for my lack of java vocabulary. I'm new to the language.

    What I have is a program that reads through a binary data file and converts it into a different binary format.

    It kicks off a thread for each file and processes them all at the same time.

    What I need is to know the progress of each of the files so I can let the user know percentage wise how much of the data has been processed so they aren't just sitting there staring at a the screen wondering what is going on.

    So my question is... how does a thread inform it's parent of something?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to get Progress updates from multiple threads...

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member Becca's Avatar
    Join Date
    Nov 2011
    Posts
    8
    My Mood
    Sleepy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get Progress updates from multiple threads...

    I will read that tutorial since I will probably need it in the future, but for now there is no progress bar. It's a command line application. I simply don't know how to pass information from a thread to the parent. Is there a way to create an event listener within the parent and then have the threads trigger the event every so often telling the parent how many bytes they have processed?

    Thanks for your help.
    Last edited by Becca; February 7th, 2012 at 12:53 PM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to get Progress updates from multiple threads...

    There's really no magic. Just call a method that updates the progress. You will probably have to worry about thread safety, but for a first stab, simply calling a method that updates the count should be okay.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member Becca's Avatar
    Join Date
    Nov 2011
    Posts
    8
    My Mood
    Sleepy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get Progress updates from multiple threads...

    Okay, I got it. Thanks so much. I always try to complicate things. =)

Similar Threads

  1. Replies: 6
    Last Post: December 9th, 2011, 05:53 PM
  2. Variable updates after loop
    By tecno40 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 9th, 2011, 05:34 AM
  3. working with multiple threads
    By retsameht in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 9th, 2010, 01:36 PM
  4. [SOLVED] Trojans with last few updates of NetBeans
    By Melawe in forum Java IDEs
    Replies: 11
    Last Post: May 22nd, 2010, 08:33 AM
  5. [Swing-Progress Bar] Can't resize progress bar
    By Grabar in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 14th, 2010, 12:27 PM