Feature Idea: allow create (new object) method to throw Exceptions #85
Replies: 2 comments
-
Hi @alexanderankin, I guess you do not care |
Beta Was this translation helpful? Give feedback.
-
BTW, regarding virtual threads vs ThreadLocal, I don't think it's a valid scenario to use object pools. Object pools are used for expensive objects that you don't want to create many times and destroy many times. E.g., you cannot create a JDBC connection per thread, or in a ThreadLocal, or per virtual thread (this would be the worst case and a disaster to you), none of the 3 patterns works for you because you will create too many expensive objects. Object pools are often used like you have 100 worker threads sharing 10 expensive objects. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to use this library over ThreadLocal since virtual threads are going to render those obsolete (new thread per task = never reusing a threadlocal), and i wanted to just pass in a lambda or method reference for the create object, so i had to add this code:
I figured it may be useful to other users of this library.
Beta Was this translation helpful? Give feedback.
All reactions