Results 1 to 2 of 2

Thread: thread

  1. #1
    manojmaddy is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default thread

    by using thread and Runnable we can implement threading concept in java but my question is that which one one is very very good and why?
    give me cause in detail.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    My suggestion is to implement a Runnable interface than to extend a Thread class. One reason is that use of an interface is more flexible than sub-classing. And the other thing I've seen is that implementing an interface keeps more open your code and you can use inheritance and stuff.

Similar Threads

  1. Difference between Thread.yield() and Thread.sleep() methods
    By Nageswara Rao Mothukuri in forum New To Java
    Replies: 12
    Last Post: 07-30-2010, 05:37 PM
  2. Trigger main thread method from secondary thread?
    By DigitalMan in forum Threads and Synchronization
    Replies: 8
    Last Post: 01-26-2010, 02:13 AM
  3. data from the main/GUI thread to another runnin thread...
    By cornercuttin in forum Threads and Synchronization
    Replies: 2
    Last Post: 04-23-2008, 10:30 PM
  4. Replies: 0
    Last Post: 01-28-2008, 07:02 AM

Posting Permissions

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