Reputation: 145
In Struts2, every request create action object. so here no thread. it fully thread safe. But how it give good performance. Here every object work in one stack. (but thread will create multiple stack for execution)
How it handle multipule requests without thread ?
Upvotes: 0
Views: 143
Reputation: 23587
In short if you know about how exactly S2 work, you will come to know why this was designed this way.
In S2 your action classes also work as Model object like transferring data from UI to the bean and from bean to UI, this is one of the reason it was decided to make New copies of Action instance for each request.
Regarding the performance if i am correct creating thread for each request, than framework has to take care of synchronizing the data so that it should be thread safe, is really a big overhead and which will in end will not improve overall performance.
S2 action are neither servlets nor controllers.I believe you are getting yourself confused with S2 filter and S2 Action classes and in end every request has its own instance of the request scoped S2 action.
Upvotes: 2