Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

For an object to be a target for a Thread, that object must be of type:

 
josephine chen
Ranch Hand
Posts: 216
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thread and runnable are true is 'nt it??
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either a Thread or a Runnable object; yes.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Err... how can a Thread have another Thread as its target? I don't see any constructors or methods which achieve this. For comparision, the constructor Thread(Runnable target) makes a runnable object the target for a Thread. But I don't see a Thread(Thread target) anywhere.
 
maha anna
Ranch Hand
Posts: 1467
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim,
Do you think the question meant this? What do you say is right.There is no Thread constructor taking a Thread object as an input.But the class java.lang.Thread class itself implements the Runnable interface which means a Thread object can be substituted for an Runnable object right? I checked this with the foll. code. It compiles and prints 'maha'.
regds
maha anna
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops. I missed the obvious. Thanks maha anna!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic