Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Are Validators thread-safe?
Can I pass a single instance of a Validator to multiple fields?
For example, if my layout has 5 "Email:" fields, can I pass the same instance of EmailValidator when I call each the five field's "addValidator" method? Or should I generate a new Validator instance for each field?
Or is it a moot question if my validators are running on the same single thread as the Application's GUI? I mean, if the validators get executed in a serial fashion in a single thread with no possibility of one validator interrupting another, then does that mean thread-safety is irrelevant and I can indeed pass a single Validator instance to many fields within a single Application instance (session)?
Within an application, validators are not run concurrently: each request from the UI is synchronized to the Application instance and background threads are not used by the framework within the handling of a request. Therefore, you can share validators within an application unless the specific validator in question has field specific state.
If explicitly using background threads: most validator implementations themselves are stateless, but when validating field values, accessing the field requires synchronizing to the application instance.