2

Threading in an application server is normally a big taboo. However, it seems quite common to use libraries that use threads on the server (spymemcached for example use a dedicated thread). Is there an acceptable way of threading on the server or are these libraries just "breaking the rules" for the sake of functionality?

I've always wondered about this but never found an answer better than "don't worry about it".

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
David
  • 375
  • 4
  • 11
  • 3
    I think it's a tabu because it's error-prone. So, it's better to avoid it, if possible, since the application server is already implicitly multithreading (resource usage is good, so there's no need to improve it with multithreading). Anyway, if it's actually needed, because you want some operations to be parallel, or because you're using a library that is agnostic to the threading of the server, then there's actually nothing wrong, as long as you are aware of the potential threading issues. – Giulio Franco Aug 21 '13 at 13:41
  • My app server had to make additional service calls, compute all results, and then take some action. I threaded those calls to make them concurrently. – Josh C. Aug 21 '13 at 13:55
  • 1
    This shouldn't be [on hold], but simply flagged as duplicate. There are already many questions an the topic, e.g. http://stackoverflow.com/questions/3212255/java-ee-specification-and-multi-threading/3212316#3212316 – ewernli Aug 22 '13 at 12:11
  • 2
    Java EE 7 has support for that ("Concurrency Utilities for Java EE 1.0", so on the GlassFish v4 you can use it. – Alexander Rühl Aug 22 '13 at 12:14

0 Answers0