Results 1 to 2 of 2

Thread: Thread creation in dm Server

  1. #1
    Join Date
    Nov 2009
    Posts
    5

    Default Thread creation in dm Server

    Hi All,

    Our application should perform long-term operations asynchronously in background from time to time (for example caches reloading). So it's very convenient for us to create separate threads for this operations.
    Could you please advice an appropriate way for threads creation in dm Server? Is it normal to create threads directly (via new Thread()..) or some thread pool should be obtained from dm Server?

    Thank you in advance,
    Ilya

  2. #2
    Join Date
    Oct 2008
    Location
    Winchester, UK
    Posts
    535

    Default

    Internally, the kernel uses KernelScheduledThreadPoolExecutor for scheduling periodic tasks. This is part of the com.springsource.kernel.services.concurrent which is not imported into the user region, so you cannot use it in an application unless you change the default configuration. KernelScheduledThreadPoolExecutor gathers statistics and IIRC names the corresponding threads appropriately.

    However, I wouldn't recommend depending on kernel internals as these are subject to change. For example, the package names will change when we donate the kernel to Eclipse Virgo.

    So you should probably use a standard ScheduledThreadPoolExecutor from java.util.concurrent or similar facilities provided by Spring. I wouldn't recommend newing up your own Threads as that's too low level and you won't get any pooling benefits.

    You may need to ensure you use the correct thread context class loader. You can get hold of the thread context class loader when an application bean is created and somehow bind it to the scheduled task's thread before calling any third party libraries that might depend on it.

    Hope that gives you sufficient food for thought.
    Glyn Normington
    SpringSource

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •