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: Questions about Threads

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Questions about Threads

    Hello,

    I've got a question or two about threads.

    I'm coding an open source game, and it has a few threads. That got me wondering, how many threads are too many? What should you always use threads for? What shouldn't you use threads for? And, is there an alternative to threads?


    Thanks.
    -Mel


  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: Questions about Threads

    This is pretty context-specific. If your game is running on mainframe with 16 cores, then by all means make a bunch of threads. But if your game is running on an old single-core processor, threading will only get you so far. So it really depends on where you're running your game, what those threads do, etc.

    I like to use a Swing Timer until I absolutely have to use 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
    Member
    Join Date
    Mar 2010
    Posts
    271
    Thanks
    21
    Thanked 7 Times in 7 Posts

    Default Re: Questions about Threads

    Hmm, never heard of a Swing Timer, I'll take a look at it. ^^

    Btw your new avatar rocks!

  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: Questions about Threads

    Quote Originally Posted by Melawe View Post
    Hmm, never heard of a Swing Timer, I'll take a look at it. ^^
    Oh man, you should definitely try using a Swing Timer before you deal with threads. Here's the tutorial: How to Use Swing Timers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

    Quote Originally Posted by Melawe View Post
    Btw your new avatar rocks!
    Heh, thanks. I created it accidentally, but I thought it looked cooler than the standard java mug.
    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. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Melawe (April 20th, 2012)

Similar Threads

  1. Redirections for many threads
    By Norm in forum Forum Updates & Feedback
    Replies: 17
    Last Post: January 5th, 2012, 07:27 AM
  2. threads
    By crazed8s in forum Threads
    Replies: 2
    Last Post: December 14th, 2010, 05:33 AM
  3. newbie help threads
    By fortune2k in forum Threads
    Replies: 19
    Last Post: October 20th, 2010, 02:40 PM
  4. [SOLVED] Questions About Threads
    By neo_2010 in forum Threads
    Replies: 4
    Last Post: March 15th, 2010, 09:04 AM
  5. threads in gui
    By urosz in forum AWT / Java Swing
    Replies: 1
    Last Post: November 3rd, 2009, 05:20 PM