Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Avin Sharma

Greenhorn
+ Follow
since Jan 17, 2013
Avin likes ...
Android Java PHP
Amritsar,Punjab,India.
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Avin Sharma

Thanks Everybody and Thanks Steve,i guess this conversation make me Clear.
5 years ago
Thank you Devaka,But Please can you elaborate your answer. I didn't get your answer though,Sorry if it seems to be Silly But i am very new to Java-Threads. I don't get stuff easily.
5 years ago
Regards,
I am new to Java. I am confused about Threads,When i am implementing thread with Runnable interface why i have to put "this" in Thread constructor.Please Explain in good Manner.Thank you

class NewThread implements Runnable
{
Thread t;
NewThread( )
{
t=new Thread(this, "Demo Thread"); //why i have to put this here
System.out.println("Child Thread:"+t);
t.start( );
} -----------*
5 years ago

Steve Luke wrote:

sr shashidhar wrote:

Avin Sharma wrote:Regards
Can anyone Tell me How many threads are running in Above Asked Program(Simple Main Method program with creating thread instance(with No extends or implements))
Thank you.



One Thread, "Main Thread"...

in each and every java program always one default thread will be running in the background i.e, "MAIN THREAD"


It's actually a little harder to answer than that, because there are extra system threads hanging around for things like Garbage Collection. You probably need a Profiler to be sure of the running thread count at any given time.



What do you mean Steve ?
@shashi- I know Main thread is there. But Dont you think there are 2 Threads here. One is Main Thread and another is of Thread class. ??
Regards
Can anyone Tell me How many threads are running in Above Asked Program(Simple Main Method program with creating thread instance(with No extends or implements))
Thank you.