Results 1 to 3 of 3
  1. #1
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Non syntax thread questions

    Is using multiple threads faster than using just one thread?
    Example, say I want to do some operation. Would that operation be faster if I splitted it into two threads?

    Example when threads can be used, other than when creating games?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Non syntax thread questions

    Example when threads can be used, other than when creating games?
    Long running tasks spawned from the EDT using AWT and Swing will lock up the GUI - perfect example of where a thread (or SwingWorker) can run in parallel so the EDT can continue to operate.

    Is using multiple threads faster than using just one thread?
    Example, say I want to do some operation. Would that operation be faster if I splitted it into two threads?
    This highly depends on the circumstances. If the work can be split up, then ok. There are occasions where splitting up an algorithm into separate threads is a pain if not impossible...there are other times where this is easy. There are times where one can spawn as may threads are there are tasks (or individual tasks for an overall goal), in which case Thread pools are probably more appropriate - each thread has an overhead...create too many and that overhead may get large enough to affect overall performance.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Non syntax thread questions

    Is using multiple threads faster than using just one thread?
    If the threads can use their own processor/core and can work in parallel, that will reduce the time taken for the job. If the threads share one processor, then the overhead of switching between threads can make the time to do the job longer.

Similar Threads

  1. Syntax Errors
    By andimiami in forum New To Java
    Replies: 8
    Last Post: 09-15-2011, 01:23 PM
  2. Main Thread not waiting for grand child thread to finish
    By prashanthn in forum Threads and Synchronization
    Replies: 3
    Last Post: 06-07-2011, 09:26 AM
  3. Couple Questions on Thread
    By Lil_Aziz1 in forum Threads and Synchronization
    Replies: 5
    Last Post: 01-06-2010, 02:02 PM
  4. Thread questions
    By McChill in forum New To Java
    Replies: 2
    Last Post: 03-17-2009, 06:48 AM
  5. Syntax Colouring
    By Doctor Cactus in forum New To Java
    Replies: 2
    Last Post: 02-16-2009, 04:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •