3

I've never had to multithread before, I understand what it is at a basic level. I'm wondering what would be the simplest and most efficent way to execute three methods at once?

e.g

public void test(){
method1();
method2();
method3();
}

Basically I want to execute 1,2 and 3 at the same time. I'm looking for any examples or resources which would be useful for doing this.

Thanks!

1 Answer 1

5

If your three methods do not share state, you can just spin up a thread for each method.

http://java.sun.com/docs/books/tutorial/essential/concurrency/runthread.html

Sign up to request clarification or add additional context in comments.

2 Comments

So I would have to make a new class?
Your class can inherit from Thread, or your class can implement Runnable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.