Re: [ljc] java concurrency in web apps

From: Gerald L.
Sent on: Thursday, March 7, 2013 7:51 AM
The Java EE spec doesn't "allow" spawning of threads, but application servers don't police this, and, as you say, threads are commonly spawned from within Java EE apps, which works just fine.

The intent of the spec was that the application server owns threads and therefore can be configured by a system administrator to manage an "optimal" number of threads for the combination of hardware, OS and Java EE apps in question. The developer of a Java EE app, so goes the thinking, doesn't have this holistic picture and so can't be trusted to manage a system-wide resource such as threads from within her own little app.

In reality, though, the only important thing to remember is that threads are scarce and the application server potentially manages a lot of them, therefore the ones spawned from the app should be of a number and lifetime that plays well within those constraints. And if you need container services (transactions, security) on those threads, then you're currently (spec-wise) out of luck (see Martijn's post and Java EE 7).

  cheers
  gerald


On Thu, Mar 7, 2013 at 12:27 AM, Jon Hatfield <[address removed]> wrote:
Hi all,

I have heard many times "do not create threads in a web app", since the container should manage them. However, the more modern APIs such as ExectorService appear to be used in web apps by some people. Can you use such java.util.concurrent classes in a wep app that requires multi-threading (e.g. due to high load), or do you forward data to a stand alone app that deals with the multi-threading? I can't find a definite answer on the internet.

Regards,
Jon




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Jon Hatfield ([address removed]) from LJC - London Java Community.
To learn more about Jon Hatfield, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, POB 4668 #37895 NY NY USA 10163 | [address removed]



--
Gerald Loeffler
mailto:[address removed]
http://www.gerald-loeffler.net

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference, in collaboration with the LJC 12/13 Jun 14

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Packt Publishing

    A publishing company specializing on specific technologies and solutions

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy