0

Why is event threads deprecated?

asked 2014-06-29 20:59:04 +0800

mpaula gravatar image mpaula
0

In ZK 7 setting "disable-event-thread" to false is deprecated. The documentation says that it's deprecated because the Servlet API does not allow the creation of threads for servlets. But as far as I know the Servlet API 3 allows the creation of threads. So, why is it deprecated now? (I understand that it is not recommended and that it may cause problems with many concurrent users. But for my application this is no problem)

delete flag offensive retag edit

Comments

Why do you have to turn it on? Everything can be created in order to avoid that, so if you have problems somewhere I can try to assist you there.

chillworld ( 2014-06-30 07:21:34 +0800 )edit

5 Answers

Sort by ยป oldest newest most voted
1

answered 2014-10-27 17:03:05 +0800

gargamel25 gravatar image gargamel25
41 2

updated 2014-10-27 20:52:34 +0800

What I understood....

It's only deprecated, so you can still use it.

It's not a best practice, because if you create another thread from it(a new modal window for example) the thread serving your request will be blocked until you close the modal window.

Now knowing the default maxThreads value for tomcat 6 is 200 See : tomcat.apache.org/tomcat-6.0-doc/config/executor.html

you can see how fast 200 users who keep a opened modal window can make the server not utilizable anymore, so it won't accept any new request.

If you use disable-event-thread = false

you can have the following command:

@Command 
public void advancedSearch() {
    Window win = (Window)Executions.createComponents("/pages/new_account.zul", null, null);
    win.doModal();
    this.newAccount = (Account) win.getAttribute("account");

}

The current thread obtained from the server thread pool is blocked until you fill all the data needed for new account. So request thread is waiting at this line win.doModal().

If you have worked with swing for example, you know it's a practice there to create modals this way, but there's only one user using the app. In a web application you should not block the request until user fills a form...

If you use disable-event-thread = true which is the default, the code will be executed right away, but win.getAttribute("account") will always return null. So you need to find another solution to get the result obtained after the modal window closes.

Hope this helps.

link publish delete flag offensive edit
0

answered 2015-01-04 14:02:28 +0800

mpaula gravatar image mpaula
0

updated 2015-01-04 14:11:39 +0800

Thanks for the answers!

As long as functionality is deprecated but still exists, I have no problem. But I fear, if it's deprecated now, then maybe in ZK 8 it will be completely removed.

The example code in the answer above shows the problem: I can no longer use normal fields to store the result of user inputs.

Yes I agree that thread creation is a problem for applications with many concurrent users. But there are applications where the developer definitely knows that there will be no more than let's say 100 concurrent users (and how many of them have a modal dialog opened at the same time?).

Furthermore I'm wondering what is the problem with many "waiting" threads? I mean the CPUs get more and more cores. The servers have RAM with sizes that some years not even hard disks had. What I want say: as a developer I like to care about the business logic and I don't want to think too much of the hardware limitations that in few years are pushed to new limits. It should be the decision of the developer when and how many threads he wants to create. He is also reponsible for the complete architecture of the application. In my opinion the framework should not limit the developer just because in few scenarios it can give problems (I'd guess that most web applications are intranet applications that are only used by few departments).

Well, hopefully I'm not alone with my way of thinking!? Any further arguments are welcome!

link publish delete flag offensive edit

Comments

What with waiting threads and you close your browser and never got the action to proceed? If you can answer this question now from your head and if that wouldn't affect your server you are on the good track, otherwise I should reconsider it.

chillworld ( 2015-01-04 14:12:26 +0800 )edit

When I create a thread I normally check regularily if user has cancelled operation or if it should timeout.

mpaula ( 2015-01-04 14:20:54 +0800 )edit
0

answered 2015-05-26 01:48:30 +0800

martindk gravatar image martindk
19 1

This thread (pun intended) just simply makes me angry. This is a clear indication that the ZK developers have simply lost touch with the needs of those who use this otherwise awesome framework. The notion that one can develop a serious web application without support for modal dialogs is ludicrous. We have built an entire open source electronic medical record and order entry system with ZK serving thousands of concurrent users and have not encountered the performance limits that you suggest. If you do remove support for event threads, we will move on to another technology. We simply will have no choice. Really, guys, pay attention to what your customers need.

link publish delete flag offensive edit

Comments

without support for modal dialogs? It's still supported, you only have to use a eventlistener to react the button pressed, the event thread disabling just enables you to work without the eventlistener, your code wait then for an action of the user.

chillworld ( 2015-05-26 07:31:33 +0800 )edit
0

answered 2015-10-13 16:41:18 +0800

mpaula gravatar image mpaula
0

@chillworld: Yes modal dialogs are still supported, somehow. But it works differently. When you have started with ZK 3 and have a working application, you just do not want to rewrite all that. It's a question of time and costs (besides the point that the source code is more straight forward with event threads).

link publish delete flag offensive edit

Comments

I understand, however you don't need to rewrite it yet, it's still there but deprecated. It's not only ZK who has this problem. See Joda time for example, DateMidnight is also deprecated so when you have time, you start to change it.

chillworld ( 2015-10-15 07:35:51 +0800 )edit
0

answered 2016-02-05 11:54:34 +0800

cor3000 gravatar image cor3000
4351 2 7
ZK Team

just for fun and example how "nice" things can be using some java 8 features

@Listen("onClick=#personSaveButton")
public void onSavePerson(){
    confirm("Confirm Save (Y/N)", this.selectedPerson, this::savePerson, this::cancelPerson); 
}

public void savePerson(Person data) {
    //do some save
}

public void cancelPerson(Person data) {
    //do some cancel
}

public static <T>void confirm(String message, T data, Consumer<T> yesHander, Consumer<T> noHandler) {
    Messagebox.show(message, new Messagebox.Button[] {YES, NO}, ce -> {
        if(YES == ce.getButton()) {
            yesHander.accept(data);
        } else if (NO == ce.getButton()){
            noHandler.accept(data);
        }
    });
}
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-06-29 20:59:04 +0800

Seen: 104 times

Last updated: Feb 05 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More