Results 1 to 2 of 2

Thread: threads

  1. #1
    Join Date
    Nov 2011
    Posts
    47
    Rep Power
    0

    Default threads

    Is there an alternative to extending class Thread for producing threadable code? If there is what does it require?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: threads

    Is there an alternative to extending class Thread for producing threadable code?
    Yes, you could not extend it, but use it as-is passing an instance of Runnable to its constructor. See Defining and Starting a Thread in Oracle's Tutorial.

    That section of the Tutorial also discusses using Executor interfaces - again pass them a Runnable and it gets run. The Executor may well do things like maintain pools or worker threads (so you don't have to).

Similar Threads

  1. New to threads
    By armyson in forum Threads and Synchronization
    Replies: 0
    Last Post: 12-09-2011, 08:52 AM
  2. Threads per Connection or Threads per Request
    By Felic in forum New To Java
    Replies: 4
    Last Post: 11-22-2011, 10:15 PM
  3. threads
    By brindha1688 in forum New To Java
    Replies: 3
    Last Post: 05-24-2011, 09:07 PM
  4. Threads
    By Tanuck in forum New To Java
    Replies: 5
    Last Post: 09-21-2010, 03:44 AM
  5. Threads!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-04-2008, 05:11 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
  •