Reputation: 177
When I write Thread.currentThread().join();
I can't execute code after that line.
If I removed it, I get error.
Is there similar of that line that let me execute the rest of my code.
Upvotes: 0
Views: 385
Reputation: 48434
Thread.join
waits for a given thread to complete (to "die" is the expression used in the docs) and resumes the current execution thereafter.
If you are joining the current thread (Thread.currentThread()
), you're essentially waiting forever, unless an InterruptedException
is caught and handled in a way that would make execution stop.
Note that whichever "error" you are getting in the lines following this is likely unrelated, and would caution a new question.
Upvotes: 4