home Forums # Technical Support Is jfuzzylite thread-safe? Reply To: Is jfuzzylite thread-safe?



thanks for your question.

The fuzzylite and jfuzzylite libraries are thread safe, but the engines are not. You can have one engine per thread, and the library will be fine sharing the factories (as long as you do not change them, which I believe there would be no good reason for that anyway). Engines, on the other hand, are not synchronized, so you will need to implement the necessary locks in order to share a single engine across multiple threads.

As for your problem, you could:
(1) synchronize the engine instance, set the input values, process the engine, get the output values, and desynchronize the instance.
(2) or have an thread pool of engines configured accordingly.

I would go for (2) because engines have a small memory footprint, and can be instantiated in advance. Synchronising the engine will allow you to use a single engine, but the performance cost on bottlenecks would probably be too high.