I have 2 threads, the main thread that is a producer, and a consumer. When the consumer throws an error, I pass it back to the main thread to throw it, but:
- Once the exception is received by the main thread, I cannot rethrow it without doing consumer.join() before, otherwise the exception is not catched.
- when an error from the main thread (that has nothing to do with the consumer) is thrown, it is catched only if the consumer has not been started (i.e ne thread is running).
it seems that all threads than the main one needs to be stopped to be able to catch errors. But it is weird. I won't add a "stopThread" function in all throws that are not related to the consumer.
I don't have code to show because this is a more general question and there might be some common rule that i don't know. don't hesitate if i lake informations.
Aucun commentaire:
Enregistrer un commentaire