sentry-java
sentry-java copied to clipboard
Reuse Timer instance
Description
Every creation of a Timer spawns a new thread. We should try to reuse an instance if possible.
Implementation note: This class scales to large numbers of concurrently scheduled tasks (thousands should present no problem). Internally, it uses a binary heap to represent its task queue, so the cost to schedule a task is O(log n), where n is the number of concurrently scheduled tasks. Implementation note: All constructors start a timer thread. See https://docs.oracle.com/javase/7/docs/api/java/util/Timer.html
Investigate the ExecutorService -> https://github.com/getsentry/sentry-java/issues/2115#issuecomment-1164459003
Should also update TransactionPerformanceCollector (#2477)