forward should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException. Uncommitted output in the response buffer is automatically cleared before the forward.
Mallik Kumar wrote:You have to obtain a lock on an object rather than a thread.
John Stark wrote:Hm, for wait() it says 'Causes the current thread to wait until ...'. I guess it is the main thread which is waiting in your code. With the wait() in your code the printout is 999999, so the main thread waits until the Thread 'thread' has finished. If you remove the wait() then the printout is something like '143' on my computer, so execution of the main thread immediately continues after doing thread.start(). Not sure why there is no notify() necessary.
John
Stephan van Hulst wrote:No, but that's the easiest way to think about it, especially when you're working with patterns that can match the empty string.
Let me give you a trivial example. Say we want to find all the instances of any character repeated *exactly* zero times. This would be the pattern: ".{0}". Let's say we want to find all the substrings of "0123" that match this pattern. Think about it, where in this input string can we find any character repeated exactly zero times?
Well, there's an empty string before the 0; there's one between 0 and 1; between 1 and 2, and 2 and 3. Finally we can also find an empty string right after 3. If it makes it easier to visualize, think of the input string like this: "" + "0" + "" + "1" + "" + "2" + "" + "3" + "".
Stephan van Hulst wrote:Because there are seven spots where you can start a sequence of zero or more characters, namely one before every character of the input string, and one after the last character of the string.
Henry Wong wrote:
Vadim Vararu wrote:
I can't get the logic here.
This compiles ok:
and this does not compile ok:
Why it doesn't use the same logic/algorithm for the method parameters. So it shortens and autoboxes it well at the variable declaration and cann't do it at the method invocation. Is here a logic or we just have to take it as a rule?
The first case is defined in section 5.2 of the JLS (assignment conversion). The second case is defined in section 5.3 of the JLS (method invocation conversion). If you look, you will notice that there is a section regarding compile time constants, in section 5.2. The equivalent to this is not present in section 5.3. This is why the first works and the second does not.
It kinda makes sense, for method parameters, the compiler must actually pass a parameter. It is not possible for a method parameter to be a compile time constant.
Henry