You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2010/01/26 21:22:35 UTC

[jira] Created: (LANG-582) Provide an implementation of the ThreadFactory interface

Provide an implementation of the ThreadFactory interface
--------------------------------------------------------

                 Key: LANG-582
                 URL: https://issues.apache.org/jira/browse/LANG-582
             Project: Commons Lang
          Issue Type: New Feature
          Components: lang.concurrent.*
            Reporter: Oliver Heger
            Priority: Minor
             Fix For: 3.0


The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.

This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated LANG-582:
------------------------------

    Attachment: BasicThreadFactory.patch

Reworked patch:
* Renamed class to {{BasicThreadFactory}}.
* A _builder_ is now used for creating instances.
* New configuration options for priority and an uncaught exception handler are supported.


> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: BasicThreadFactory.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated LANG-582:
------------------------------

    Attachment: BasicThreadFactory.patch

Reworked patch:
* Renamed class to {{BasicThreadFactory}}.
* A _builder_ is now used for creating instances.
* New configuration options for priority and an uncaught exception handler are supported.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell closed LANG-582.
------------------------------

    Resolution: Fixed

Had a spare cycle, so committed the patch:

svn ci -m "Adding BasicThreadFactory class. Same as Oliver's original patch in LANG-582, with an @since 3.0 added" src
Adding         src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java
Adding         src/test/java/org/apache/commons/lang3/concurrent/BasicThreadFactoryTest.java
Transmitting file data ..
Committed revision 916095.


> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: BasicThreadFactory.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated LANG-582:
------------------------------

    Attachment:     (was: BasicThreadFactory.patch)

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12830662#action_12830662 ] 

Henri Yandell commented on LANG-582:
------------------------------------

Why 'ThreadFactoryImpl' and not 'BasicThreadFactory' or 'DefaultThreadFactory'? Or Simple or something. I like the Basic one.

+1 to the builder.

I'm wondering if I should change UnicodeUnescaper to a Builder approach. I liked the notion of an enum being used as args, but it doesn't support values so better to use the more common idiom.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: lang-threadfactoryimpl.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated LANG-582:
------------------------------

    Attachment: lang-threadfactoryimpl.patch

This patch contains a default implementation of the {{ThreadFactory}} interface and a corresponding unit test class.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: lang-threadfactoryimpl.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12805831#action_12805831 ] 

Henri Yandell commented on LANG-582:
------------------------------------

Sounds like a good idea, +1.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: lang-threadfactoryimpl.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837710#action_12837710 ] 

Henri Yandell commented on LANG-582:
------------------------------------

+1 to the patch.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: BasicThreadFactory.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12806678#action_12806678 ] 

Oliver Heger commented on LANG-582:
-----------------------------------

I am not sure about the API if more configuration options are added.

On one hand I would like to avoid set methods so that all member fields can be made *final*, and the class is immutable. On the other hand this gets messy with the various constructors.

An option could be using a _builder_. Then the creation of a {{ThreadFactoryImpl}} instance could look as follows:

{code}
ThreadFactory factory = new ThreadFactoryImpl.Builder()
    .namePattern("my thread %d")
    .priority(0)
    .daemon(true)
    .uncaughtExceptionHandler(handler)
    .build();
{code}

Would this be an option to go? I think, this is not the typical style used within [lang], but for the use case it is appropriate.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: lang-threadfactoryimpl.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated LANG-582:
------------------------------

    Attachment:     (was: lang-threadfactoryimpl.patch)

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-582) Provide an implementation of the ThreadFactory interface

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12830726#action_12830726 ] 

Oliver Heger commented on LANG-582:
-----------------------------------

BasicThreadFactory is fine with me.

> Provide an implementation of the ThreadFactory interface
> --------------------------------------------------------
>
>                 Key: LANG-582
>                 URL: https://issues.apache.org/jira/browse/LANG-582
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.concurrent.*
>            Reporter: Oliver Heger
>            Priority: Minor
>             Fix For: 3.0
>
>         Attachments: lang-threadfactoryimpl.patch
>
>
> The Executor framework in Java 1.5 uses the {{ThreadFactory}} interface for creating new threads on demand. Currently there is no base implementation of this interface. So if an application needs to configure threads used by an {{ExecutorService}}, it has to create a custom implementation.
> This is a proposal to add a default {{ThreadFactory}} implementation which allows an application to configure some options of the threads to be created. Especially the names of newly created threads and their daemon status can be configured. Maybe the configuration options can be extended, e.g. for specifying a priority or an uncaught exception handler.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.