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

}
}

> 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.

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 :)

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.

;-)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.