Skip to content

Improve SessionPoolExample by replacing unbounded fixed thread pool w…#17269

Open
anusha975 wants to merge 1 commit intoapache:masterfrom
anusha975:fix-threadpool-example
Open

Improve SessionPoolExample by replacing unbounded fixed thread pool w…#17269
anusha975 wants to merge 1 commit intoapache:masterfrom
anusha975:fix-threadpool-example

Conversation

@anusha975
Copy link

This PR improves the SessionPoolExample by replacing the use of Executors.newFixedThreadPool() with a ThreadPoolExecutor backed by a bounded queue.

Motivation:
Executors.newFixedThreadPool internally uses an unbounded LinkedBlockingQueue, which may allow unlimited task accumulation and potentially lead to OutOfMemoryError in high-throughput scenarios.

Since this is an official example, using a bounded queue demonstrates safer best practices for users.

Changes:

  • Replace Executors.newFixedThreadPool with ThreadPoolExecutor
  • Use ArrayBlockingQueue with bounded capacity
  • Add explanatory comment

This change only affects example code and does not modify core IoTDB functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant