0

can we run a run() method with out using a start() method in a program?

public class A extends Thread
{
public void run()
{

System.out.println(" i will execute any way");

}

public static void main(string args[])
{

A a=new A();

a.run(); // no start method

}
}

4
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by ProgrammersTalk
0

> can we run a run() method with out using a start() method in a program?
Yes, but it won't work the way you expect it to work.

Calling the run() method directly would be like calling a normal method. No thread of execution is created, no concurrency. On the other hand, calling the start method spawns a new thread of execution which can execute concurrently with other threads by executing the run() method.

0

Yes, but it won't work the way you expect it to work.

it will work!!! but only as a method, not thread. It won't run simultaneously :)

0

it will work!!! but only as a method, not thread. It won't run simultaneously :)

If you read his thread,
that is exactly what he said.

;-)

0

If you read his thread,
that is exactly what he said.

;-)

haha sorry, I just realized that once I re read it again... my bad... XD

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.