home Forums # Technical Support How to use fuzzylite with Apache Spark Reply To: How to use fuzzylite with Apache Spark


Hi phil,

thank you for your post.

jfuzzylite can be used in Apache spark for java. The only bits to be careful about when using jfuzzylite in multiple threads are:
– Factories: The component factories (e.g., TermFactory, DefuzzifierFactory) need to be set up once and remain unchanged to avoid race conditions. I cannot see a scenario where you would like to register and deregister components at runtime, but if you need that, then you will have to synchronize the factories to avoid race conditions of multiple threads changing them.

– FuzzyLite configuration: Same as before, the FuzzyLite.java class contains static variables for formatting floating-point numbers with a specific number of decimals, determine whether logging is to be made, amongst others. It is all fine if different threads share the same configuration, but if you need different threads to use different number of decimals, then these variables will need to be modified to be ThreadLocal.

The jfuzzylite (and fuzzylite) are fine to be used in multi-threading environments provided that either (1) factories and configuration are not modified across threads, or (2) synchronisation mechanisms are put in place to modify them.

Let me know if you have further questions.