Announcement Announcement Module
Collapse
No announcement yet.
Thread creation in dm Server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X