dinesh707
dinesh707

Reputation: 12582

How to start a finished thread again?

I run some code inside a thread (A). At the end of that thread it creates another thread (B). Now what i want to do is at the end of thread B, i need to call thread A. when i do

_threadA.start() from thread B system says: Thred alread started.

how to fix this?

Upvotes: 3

Views: 2272

Answers (2)

itsrajesh4uguys
itsrajesh4uguys

Reputation: 4638

If you want to create a stopped thread means you should call again the stopped thread. that's only the way to do it .

Upvotes: 0

Óscar López
Óscar López

Reputation: 235984

You have to understand the life cycle of threads; after a thread is started it can not be restarted - the same applies for a stopped thread, once it's stopped its life cycle is over. Take a look at the linked article, in particular the state diagram will make things clear.

Upvotes: 5

Related Questions