> I mean how do I know a thread is ended?
By calling join.
That's the simplest way, if you only need to know when all threads are done. If you want to know as soon as each one is done, without having to worry about the order or waiting till they're all done, then when each thread finishes, it will have to call some method on some shared object that the main thread can observe.