Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.

Paul Clapham

+ Follow
since Oct 14, 2005
Paul likes ...
Eclipse IDE Firefox Browser MySQL Database
Forum Moderator
Paul Clapham currently moderates these forums:
Vancouver, Canada
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Clapham

Paul Clapham wrote:... from the ServletContextEvent object passed to the contextInitialized method you can get a ServletContext; to add an object to application scope you can call its setAttribute(name, object) method.

1 week ago

Vaibhav Gargs wrote:Can we have something like once T2 is done its processing it informs T1 that it has done the processing even though T1 can continue its normal execution?

Of course you could do that. But I'm not sure why that would be useful. Is it the case that at some point T1 is going to need the data from T2? In that case T1 should do everything which doesn't depend on T2 and then get the data from T2. It may have to wait, but that's not a problem because it can't do anything else anyway. Or if T1 doesn't ever need the data from T2, then there's no point in informing T1 that T2 is complete. Or at least you haven't described a situation where T1 only needs to know that T2 is complete but doesn't need its data.
Execute code on webapp startup and shutdown using ServletContextListener

To that I would add: from the ServletContextEvent object passed to the contextInitialized method you can get a ServletContext; to add an object to application scope you can call its setAttribute(name, object) method. Elsewhere in your app you can easily get a ServletContext and call getAttribute(name) to retrieve that object, or in JSTL it's very easy to access objects in application scope.
1 week ago
Wasn't me insisting.

Vaibhav Gargs wrote:I found that CompletableFuture was added in JDK8 but we are using JDK6. So, what would be the solution in lower versions?

So you're going to have an ExecutorService whose job is to run a collection of threads which each do long-running computations? In this case what you do is to start all of the long-running computations running, then wait for them all to finish. Using Future.get() would be a good way to do that waiting.

Now you might think that it's important to get the results of those long-running computations in some special order, so that you can minimize the elapsed time. But if you think about it for a while you'll realize that the order in which you wait for those results doesn't matter. No matter which order you choose, the total elapsed time is going to be the elapsed time of the longest-running computation.
It seems to me that if those lists belong to the application, and aren't specific to any particular user, then you should be putting them in application scope rather than in session scope. That way you'd only have to create them once, when the application starts, instead of having to create them every time a new session is created. Likewise there'd be only one copy of the lists instead of having a copy for each active session.

Note: this assumes that the contents of the lists don't ever change. If they do, then you need to have a way for the application to reload the lists when such a change happens. This can be done, of course, but it's something that needs to be included in your application's design.
1 week ago

Sam Ritter wrote:What ModalityType is the equivalent of setModal(true)?

I don't know, I've never seen that before. I've always just created modal dialogs like Norm did, in fact I don't think I've ever needed a non-modal dialog.

Anyway the docs for setModalityType say

The API documentation wrote:Note: changing modality of the visible dialog may have no effect until it is hidden and then shown again.

Perhaps that's an issue in your case -- if you still care.
1 week ago
Is it possible that on your machine, your code and the database were both running on the same machine? Whereas on your VPS, the database is running on a different machine and the query results have to be sent over the network?
1 week ago

Vaibhav Gargs wrote: it will turn out to be a huge performance impact. So, how can we overcome this problem?

Perhaps you could explain more about why you think there will be a "huge performance impact". The first thing for us to know is what you are comparing this technique to. In other words, "Compared to X technique the use of Future.get() produces a performance impact". The second thing for us to know is what you mean by "performance" in that statement. I suspect you're talking about elapsed time but it would help for us to know that before we rush off to produce "solutions".
If you run your class using the "java" command then you get a console to see its output and accept its input. If you use the "javaw" command then you don't. So you'd have to examine which of those two commands is run by the double-click action.
2 weeks ago
Seems to me that you might be able to create a lot of havoc by extending java.lang.Class and then persuading user code to use your extension. Language designers don't like havoc being created like that, it makes it hard to design a language which works in a rational and predictable way.
2 weeks ago
You're asking how the various database systems execute those statements?

S Fox wrote:If he doesn't post here anymore can I have his cows? I only have one cow and it's lonely.

He still posts, he just doesn't get involved in answering Java questions. But I feel for your cow so I'll give it a mate.
2 weeks ago

Peter Seeger wrote:I want someting in a for loop to run through every time (Yes, that works!) But the variable that you are counting up to end the loop at some point should only increase e.g every five times.

Normally when you write a for loop with a counter as its index, the loop-ending value is constant. So perhaps it's the index variable which you want to increase every five times? But that doesn't make any sense to me either; do you really want the index variable to go 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, ... and so on? I suspect not.

In which case I'm stuck. Your code doesn't help, but that isn't surprising because you tried to write it to explain your problem even though writing the code is the thing you're having a problem with. So I agree with Carey -- an English description of what you want to do would be a good start. An English description which doesn't use the words "array" or "list" would be even better.
2 weeks ago
++ what Tim said.

If I wanted to learn how to take off a sink trap so that I could clean it (or get out the valuable thing that I dropped into it) then a video would be ideal. But for programming? Can I download the example code from a video? Can I scan through the video quickly to see where it mentions the groupingBy() method, or do I have to wait for five minutes until it gets around to that? I don't have enough lifetime left for that.
2 weeks ago