[TYRUS-200] [client] Provide facility for thread factory (worker & selector thread) Created: 18/Jun/13  Updated: 18/Jun/13  Resolved: 18/Jun/13

Status: Resolved
Project: tyrus
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.1

Type: Improvement Priority: Major
Reporter: Pavel Bucek Assignee: Pavel Bucek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
is duplicated by TYRUS-194 Provide API for setting worker/select... Resolved


From the developer's angle, perhaps they would like to see ExecutorService rather than Grizzly thread pool (even though grizzly's threadpool seems to offer more options) . For e.g.

ClientManager client = ClientManager.createClient();
client.getProperties().put("...", Executors.newFixedThreadPool(5));

I also prefer passing Map to ClientManager.createClient(Map<String, ?> props) so that changing properties after client is created would mean subtle behavioral changes.

Comment by Pavel Bucek [ 18/Jun/13 ]

Fixed in the trunk.

Now you can set worker and selector ThreadPoolConfig used by grizzly container when creating Tyrus client. Following sample only sets ThreadFactory, but there are many more options which you can modify (pool size, memory management, queues, ..)

            ClientManager client = ClientManager.createClient();

            client.getProperties().put(GrizzlyClientSocket.WORKER_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory(new ThreadFactory() {
                public Thread newThread(Runnable r) {
                    // ...

            client.getProperties().put(GrizzlyClientSocket.SELECTOR_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory(new ThreadFactory() {
                public Thread newThread(Runnable r) {
                    // ...


See ThreadPoolConfig javadoc for more details: https://grizzly.java.net/docs/2.3/apidocs/org/glassfish/grizzly/threadpool/ThreadPoolConfig.html

feel free to comment/reopen if this solution is not sufficient for your usecase.

Generated at Sun Jul 24 17:47:49 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.