Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thread and runnable are true is 'nt it??
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either a Thread or a Runnable object; yes.
 
Wanderer
Posts: 18671
  • 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.
 
Ranch Hand
Posts: 1467
  • 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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops. I missed the obvious. Thanks maha anna!
 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic