Cycling74 / min-devkit

Tools, documentation, and reference implementation of a Max Package built using the Min-API.
MIT License
158 stars 31 forks source link

Detached Thread causing Max to not exit completely #152

Closed mourendxu closed 4 years ago

mourendxu commented 4 years ago

Hi, has anybody ran into this issue?

I wrote an external that uses a detached thread. I then used condition variable and locks to coordinate the exit of the detached thread. Both the main thread and the detached thread print a notification to the console right before they return/exit. All the statements were printed to the console in the correct order.

Yet, when I try to close Max, it would go into background process, stay there, take up about 17-18% of CPU. I tried to debug that thread once, and I got a bunch of memory access violations.

I used the same scheme for another program, and everything seems to be fine there.

I am quite confounded as to why this is.

Thank you.

mourendxu commented 4 years ago

I switched my code to joinable thread, the problem went away.

tap commented 4 years ago

Great! Thanks for the update!

mourendxu commented 4 years ago

Oh, I was hoping an explanation why that is? :D

Thanks

tap commented 4 years ago

Without concrete source code it is hard to guess. A joinable thread seems most appropriate, however, as the resources are properly and predictably cleaned-up.

Cheers

mourendxu commented 4 years ago

Ahh ok. Thanks. When I am ready to release the code, I might re-open this.

Thank you for your reply.