Reputation: 333
Say I call a thread's method from inside another thread as such
public static void main(String[] args)
{
//do something
TestThread thread = new TestThread();
thread.start();
thread.doSomething();
//Part A
}
class TestThread extends Thread
{
public void run()
{
//do something
}
public void doSomething()
{
//Do something
}
}
Will the program do everything in the doSomething()
method before moving onto partA or will it start running the doSomething()
method then move straight onto part A?
I'm making an application with a server serving multiple clients and want the server to be able to quickly move through the requests, so it should be once it is sent it moves on rather than waiting for the client to process the instruction.
Upvotes: 1
Views: 43
Reputation: 73528
No. The main thread will run doSomething()
while the thread
-thread will be running run()
as usual.
Just because doSomething()
is in a class that extends Thread
doesn't mean that there's anything special about it as a method.
Upvotes: 3