tyrus
  1. tyrus
  2. TYRUS-287

Cannot create non-daemon threads with Tyrus server standalone mode

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.3
    • Fix Version/s: 1.4
    • Component/s: server
    • Labels:
      None

      Description

      Currently, a standalone Tyrus server makes all of its threads daemon threads so that I'm forced to run another random thread in order to keep the JVM from terminating. It would be nice to have an option (in the "properties" map argument to org.glassfish.tyrus.server.Server perhaps?) to make Tyrus's threads regular style threads.

        Activity

        Hide
        Pavel Bucek added a comment -

        True, Server class needs more improvements. We plan to have something sorted out for 1.4 release, so stay tuned (this issue will be most likely fixed during that process, will keep it open and updated).

        Thanks for reporting this!

        Show
        Pavel Bucek added a comment - True, Server class needs more improvements. We plan to have something sorted out for 1.4 release, so stay tuned (this issue will be most likely fixed during that process, will keep it open and updated). Thanks for reporting this!
        Hide
        Pavel Bucek added a comment -

        Fix merged to master branch. Now you can configure thread pools which will be used by Grizzly server container:

                final HashMap<String, Object> properties = new HashMap<String, Object>();
        
                properties.put(GrizzlyServerContainer.WORKER_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory(new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable r) {
                        Logger.getLogger(GrizzlyClientThreadPoolConfigsTest.class.getName()).log(Level.INFO, "Worker thread factory called: " + r);
                        return new Thread(r);
                    }
                }));
        
                properties.put(GrizzlyServerContainer.SELECTOR_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory(new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable r) {
                        Logger.getLogger(GrizzlyClientThreadPoolConfigsTest.class.getName()).log(Level.INFO, "Selector thread factory called: " + r);
                        return new Thread(r);
                    }
                }));
        
        
                final Server server = new Server(properties /*, additional params like endpoint classes etc */);
                server.start();

        (there is plenty of properties which you can set, just take a look at ThreadPoolConfig javadoc: https://grizzly.java.net/docs/2.3/apidocs/org/glassfish/grizzly/threadpool/ThreadPoolConfig.html

        Feel free to comment, reopen this issue or create new one if you want this feature improved.

        Show
        Pavel Bucek added a comment - Fix merged to master branch. Now you can configure thread pools which will be used by Grizzly server container: final HashMap< String , Object > properties = new HashMap< String , Object >(); properties.put(GrizzlyServerContainer.WORKER_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory( new ThreadFactory() { @Override public Thread newThread( Runnable r) { Logger.getLogger(GrizzlyClientThreadPoolConfigsTest.class.getName()).log(Level.INFO, "Worker thread factory called: " + r); return new Thread (r); } })); properties.put(GrizzlyServerContainer.SELECTOR_THREAD_POOL_CONFIG, ThreadPoolConfig.defaultConfig().setThreadFactory( new ThreadFactory() { @Override public Thread newThread( Runnable r) { Logger.getLogger(GrizzlyClientThreadPoolConfigsTest.class.getName()).log(Level.INFO, "Selector thread factory called: " + r); return new Thread (r); } })); final Server server = new Server(properties /*, additional params like endpoint classes etc */); server.start(); (there is plenty of properties which you can set, just take a look at ThreadPoolConfig javadoc: https://grizzly.java.net/docs/2.3/apidocs/org/glassfish/grizzly/threadpool/ThreadPoolConfig.html Feel free to comment, reopen this issue or create new one if you want this feature improved.

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            brian_gordon
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: