I have generated code from an openapi yaml file. I'm implementing the handleRequest methods. I need to share the same instance of a "Util" object to reuse it in all the handleRequest calls. Could you please tell me where to store my Util object instance? My Util class is not thread safe, so I should have one instance for each client thread.
How to share a util object which is not thread safe in light-4j handler
40 Views Asked by Steve Hu At
1
There are 1 best solutions below
Related Questions in THREAD-LOCAL
- How to store per thread contextual data in c#?
- How to instantiate Spring bean with custom scope and @Autowired dependencies?
- Akka actors and shared data: thead-safe, thread-unsafe, or ThreadLocal?
- InheritableThreadLocal value not inherited by ExecutorService threads
- Do operations on ThreadLocal have to be synchronized?
- How to trace request process when using NIO or event-driven framework like Netty
- Non-static global variable vs. global static __thread variable
- Spring and ThreadLocal
- Segmentation fault when accessing statically initialized __thread variable
- Kotlin delegate property by lazy that is thread local
- C++ Member variable copied for each thread (thread_local-like)
- static variable thread_local with open_MP
- Is ThreadLocal allocated in TLAB?
- Is it a good idea to use ThreadLocal as a context for data?
- Effect of ThreadLocals and side-by-side classloading
Related Questions in NON-THREAD-SAFE
- How can I make my flask + sqlite3 application threadsafe
- RHEL PHP 8.0 Non-Thread Safe Compilation
- Java class annotated with non thread safe
- unsynchronized read/write of variables may cause data race?
- Running Selenium Webdriver tests with TestNG in parallel does not sent correct data to browser
- How to share a util object which is not thread safe in light-4j handler
- Is this null pointer exception in TreeMap due to concurrent access?
- Making Thread run a Jframe
- Initializing a static Java constant from a non-thread-safe method
Related Questions in LIGHT-4J
- I'm planning to develop an OAuth server in a monolith, can we use light-oauth2 as libraries in our app instead of microservices?
- Add aditional information to json-schema and get it when validate through the networknt json validator
- How to validate array item types with networknt/json-schema-validator?
- How to validate against an OpenAPI schema with $refs using json-schema-validator
- How to validate JSON with schema which contains a reference to another schema?
- Light4J Oauth2 docker-compose error's saying Cannot locate specified Dockerfile
- How to Add Custom Json Schema Validators
- Is there any real light 4j examples for mapping json request to Java POJO objects?
- Is Light-4j similar to the AOP programming?
- Printing query parameters in access log for light-4j application?
- How to create light-4j fatjar for Docker
- How do we integrate access log in logback.xml for light-4j app?
- Light-oauth hazelcast purpose
- Light-OAuth2 Refresh Tokens live forever? (Must be explictly deleted)
- when starting light-oauth2 images, it shows no route handler provider available in service.yml
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If your class is thread safe, the best place is https://www.networknt.com/concern/service/
If the object is not thread safe then save one object per thread with ThreadLocal. That means one request might be calling two or more instance of util objects when a request is dispatched from an IO thread to a worker thread.
If it's actually a util object can you make it stateless so that it is thread safe? Maybe add an additional context type object for the state if you really need it. Attaching it to the exchange as an attachment could work.