Skip to content

Are pi4j-v2 provides thread-safe? #158

Answered by taartspi
tatery asked this question in Q&A
Discussion options

You must be logged in to vote

Executing the MCP23017 example, there is a lock synchronization for the i2c path in the LinuxFSI2CBus, so I believe this multiThread concern is addressed at present. public R execute(I2C i2c, CheckedFunction<LinuxFile, R> action) {
if (i2c == null) {
throw new NullPointerException("Parameter 'i2c' is mandatory!");
} else if (action == null) {
throw new NullPointerException("Parameter 'action' is mandatory!");
} else {
try {
if (!this.lock.tryLock() && !this.lock.tryLock(this.lockAquireTimeout, this.lockAquireTimeoutUnit)) {

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by eitch
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@taartspi
Comment options

@savageautomate
Comment options

@eitch
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants