suraj p
suraj p

Reputation: 11

Set Thread priority to execute same method

Here is my conditions: I have two threads, t1 and t2. Both are running. Now, I want to call the method m1() by using both threads, but t2 should execute m1() first, and then t1 will execute next after t2. How can I achieve this?

Upvotes: 1

Views: 57

Answers (1)

manash
manash

Reputation: 7106

You can set your method as synchronized so that m1() can't be executed concurrently by multiple threads.

Upvotes: 1

Related Questions