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: Can a lot of threads slow down my program?

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Location
    Europe, Lithuania
    Posts
    10
    My Mood
    Where
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can a lot of threads slow down my program?

    Hi, i've created an explosion animation with many particles. For each particle is created a new class with thread that waits for particle lifetime to end and then kills that particle. So can that many threads slow down program?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,299
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: Can a lot of threads slow down my program?

    Yes, extra threads can slow down a program.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Location
    Europe, Lithuania
    Posts
    10
    My Mood
    Where
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can a lot of threads slow down my program?

    So is it possible to create one thread for all particles
    ?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,299
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: Can a lot of threads slow down my program?

    Yes, it should be possible for one thread to handle them. Use an event queue to keep track of when the next particle death should occur. Perhaps a Timer with delay would work.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jun 2014
    Location
    Europe, Lithuania
    Posts
    10
    My Mood
    Where
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can a lot of threads slow down my program?

    Thanks for your time, i will try it.

Similar Threads

  1. Threads in BankAccount program
    By ben-der in forum What's Wrong With My Code?
    Replies: 22
    Last Post: March 15th, 2012, 11:19 AM
  2. Parking Lot Program help!
    By soul.salem in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 23rd, 2011, 10:35 PM
  3. Blackjack program runs excrutiatingly slow.
    By sina12345 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 10th, 2010, 04:55 AM
  4. Crawler is getting slow
    By manokrrish in forum Threads
    Replies: 3
    Last Post: October 18th, 2010, 10:24 AM
  5. A java beginner needs a lot of help and ideas
    By vesa in forum Java Theory & Questions
    Replies: 1
    Last Post: May 24th, 2010, 10:46 PM