Pi4J / pi4j-v1

DEPRECATED Java I/O library for Raspberry Pi (GPIO, I2C, SPI, UART)
http://www.pi4j.com
Apache License 2.0
1.31k stars 447 forks source link

Threads created on each event never terminate? #479

Closed qzic closed 4 years ago

qzic commented 4 years ago

I have a bunch of digital listeners on a set of gpio pins. They fire appropriately but each event creates a 2 new threads (high->low and low->high) which never terminate. Should they not terminate after the event handler returns? This happens even if the event handler does nothing but return. Is this a bug or is there some solution?

eitch commented 4 years ago

@qzic I have just added a change to perform single threaded GPIO event firing on my branch ( https://github.com/Pi4J/pi4j/issues/489 ). While checking the code i am pretty sure that what you are seeing is just the default cached thread pool, which would only stop the thread if it deems it necessary. I don't think this is an issue and would close it. If you prefer less threads, then use the single threaded executor service

eitch commented 4 years ago

I have also seen that there was a situation where the native C thread binds to the JVM on every interrupt, this has been changed as well, so you might also have seen this happening. Closing now, as the binding is now only done once on registering of the first interrupt handler.

savageautomate commented 3 years ago

@eitch 's changes are in the v1.4 branch. Moving this issue to v1.4 for tracking purposes.