Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Thread t1 = new Thread(){
public void run(){
for(int i = 1;i <= 10;i++)
{
System.out.println(i);
}
}
};
Posted
Comments
[no name] 18-Jul-14 9:08am    
And what is it that you do not understand?
Member 10955789 21-Jul-14 6:04am    
how are we using "{some code}" right after creating an object of thread class?? Plz explain the execution sequence here...
Richard MacCutchan 19-Jul-14 4:43am    
Why not build it, and use your debugger to step through and see what is happening?
nitrous_007 19-Jul-14 11:03am    
http://www.codeproject.com/Articles/64628/Code-Project-Quick-Answers-FAQ

Section 4. Subsection 1

:)

Same as below Code. It creates a thread with a function as argument. starting the thread executes the function.

C#
Thread t1 = new Thread(new ThreadStart(run));
t1.Start();

public void run()
{
    for(int i = 1;i &lt;= 10;i++)
    {
    System.out.println(i);
    }
}
 
Share this answer
 
v2
Comments
Member 10955789 21-Jul-14 5:19am    
how are we using "{some code}" right after creating an object of thread class?? Plz explain the execution sequence here...
got it. It was anonymous class concept. I haven't actually heard about irt before so I didn't understand the code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900