How Action class in struts2 Handle Multithreading

Ajay Pandey

Ajay Pandey

@ajay-pandey-Zkxqb6 Oct 22, 2024
How Action class in Struts2 handle multiple requests from client.Action class is not thread safe in struts2.How to handle concurrent requests.................

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Nov 20, 2013

    They don't have mutable class objects.
    If action class will have mutable class object then it will be problematic in mutithreading.
  • Ajay Pandey

    Ajay Pandey

    @ajay-pandey-Zkxqb6 Nov 20, 2013

    My question is how action class in struts2 ensure concurrency(thraed safty)...... I know action class is normal java class.I am working as java developer since last 2 year.Now my application working in multithreaded enviorment and its working fine .But how action class work........?
  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Nov 20, 2013

    I don't have access to machine right now.
    I think there is saparate action classes classes are instantiated for each request.
    Can you make a instance variable and keep in loop in execute method. See how it works ?
    But I am sure there only one object cearted for FilterDispature servlet.
  • Ajay Pandey

    Ajay Pandey

    @ajay-pandey-Zkxqb6 Nov 20, 2013

    thanks ianoop.I highely appreciated ur valuable responce.
    I got answer from my "black book for struts2".Struts 2 Action objects are instantiated for each request, so there are no thread-safety issues.Actually FilterDispature servlet object created wn request maps in web.xml to varify url and call for ActionMapper class.
  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Nov 20, 2013

    Yes this is difference between struts 1 and 2 .
    In struts 1 only one object of action will be created.
  • micheal john

    micheal john

    @micheal-john-l1fIn3 Nov 28, 2013

    ianoop
    Yes this is difference between struts 1 and 2 .
    In struts 1 only one object of action will be created.

    Guys i'm new to java frameworks please suggest me some main topics to be covered in spring and struct