This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-05
Channels
- # announcements (1)
- # babashka (7)
- # beginners (60)
- # biff (7)
- # cider (2)
- # clj-kondo (1)
- # clojure (15)
- # clojure-france (1)
- # clojure-norway (1)
- # clojurescript (7)
- # datascript (7)
- # emacs (4)
- # etaoin (1)
- # honeysql (7)
- # interceptors (8)
- # introduce-yourself (3)
- # kaocha (1)
- # off-topic (16)
- # pathom (2)
- # reagent (15)
- # reitit (11)
- # releases (1)
- # slack-help (3)
- # vim (36)
Has anyone played around with monitoring (Executors/newSingleThreadScheduledExecutor)
? I can construct one and it seems to function as expected but I can't seem to introspect on it for monitoring. :thinking_face:
Others may have more informative answers, but a quick search found this StackOverflow Q&A, with links to a couple of earlier ones: https://stackoverflow.com/questions/10510300/java-thread-pool-executor-monitoring
Thanks, @U0CMVHBL2 :) Trying to check this out but SO appears to be down for maintenance on my side. I will say that I'm able to monitor the FixedThreadPool just fine. I'm still resisting putting a small Java program together just to prove that this isn't something weird with my environment but I'm suspicious that I'm just not understanding the reflection/module behavior well enough.
It is pretty much Google's reason for being, so if they are bad at it, then someone else will eat their lunch.
You know I bet this is some kind of wrapper class that has the scheduled thread executor as a member or something…
getPoolSize
exists on ThreadPoolExecutor
, which is what newFixedThreadPool
actually returns. But it doesn't exist on ExecutorService
.
newSingleThreadScheduledExecutor
does not return an instance of the ThreadPoolExecutor
class.
LOL >
> /**
> > * A wrapper class that exposes only the ExecutorService methods
> > * of an ExecutorService implementation.
> > */
> >
https://github.com/openjdk-mirror/jdk7u-jdk/blob/f4d80957e89a19a29bb9f9807d2a28351ed7f7df/src/share/classes/java/util/concurrent/Executors.java#L623-L624@U2FRKM4TW Yep yep.
So I guess I'm going about this wrong here. My hope was to have a scheduler executor service for scheduling future tasks in a non-blocking way that I could emit metrics on from a separate thread like how big the queue is, how many tasks have completed, etc. Is there a better Java concurrency utility for accomplishing this with?
Actually I bet it's literally this simple
(.getPoolSize (Executors/newScheduledThreadPool 1))
I think the reason for the Delegate class is because of the line > Unlike the otherwise equivalent newScheduledThreadPool(1) the returned executor is guaranteed not to be reconfigurable to use additional threads. So that would necessitate hiding its instance methods behind the Delegate class such that they can't be messed with, I suppose.