comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Classes in jar can't load - why? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc2f55bd4b5e0165 * Sort in the Descending Orger with Index - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ea7449282262ca6 * Debugging ANT build scripts - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a174637837f5a523 * Commons logging question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/148ce5bb9c7abd0c * Struts Server-Side Form Validation - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e8d7503f3780d747 * Singleton or static class? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6605e437a9085c2 * TOMCAT/MYSQL/JSP - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6cfdfa12d76632b1 * JSTL pages communications - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/25e8e7ed7d7eb6db * How to escape hex digits in a regular expression!!! - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3950cae896bde7a4 * performance of double checked locking - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6881393065d8371a * Reading HTML contents from the server - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2f868e582b49802 * Strategy & Delegation - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b71cbc628cc61da * Algorithm, please help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8bcd7defb3cda029 * Aw Ma - Do I *have* to use tags? ;-( - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9fcfc4eec9ac055f * timout on line of code - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/85ddb5609baca4a0 * Java and inlining - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b13dd1cb6d5e4bd0 ============================================================================== TOPIC: Classes in jar can't load - why? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dc2f55bd4b5e0165 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 1:31 pm From: "Jack Andersson" > That would be a wise decision for learning the ropes, as it would > force you to think in terms of what's going on, instead of in terms of > auto-completion and something magically and inexplicably turning > red in your IDE. Auto completion is gods gift to programmers. I can't believe that someone with serious intentions of developing java code quickly and efficiently would think differently. It stunning how programmers tends to love stone age methods and how they tend bo be very reactionary. Somehow this discussion reminds me of when some jerks back in the 90s claimed that internet only should contain text and no picture. > Claim what you will. It's your private problem. Thank you. I happy to announce that my "private problem" has speeded up my programming with 100% or more. == 2 of 2 == Date: Fri, Dec 17 2004 1:16 pm From: Tilman Bohn In message <[EMAIL PROTECTED]>, Jack Andersson wrote on Fri, 17 Dec 2004 13:31:13 +0100: [...] > Auto completion is gods gift to programmers. I can't believe that someone > with serious intentions of developing java code quickly and efficiently > would think differently. I don't. I'm using it all the time myself. I did specifically say: `to learn the ropes'. > It stunning how programmers tends to love stone age > methods and how they tend bo be very reactionary. This thread was about understanding how something works and why something `unexpected' happened. I'm not advocating doing everything by hand in everyday work. My point is simply, if you've never done it by hand at all, sooner or later you'll be baffled by your tools, because you don't know what's going on under the hood. -- Cheers, Tilman -- `Boy, life takes a long time to live...' -- Steven Wright ============================================================================== TOPIC: Sort in the Descending Orger with Index http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ea7449282262ca6 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 1:27 pm From: Thomas Weidenfeller Luigi Napolitano wrote: > for (i = 0; i<=2; i++) > cout<<z[index[i]]; > Output: [ 2, 3, 1 ] This is C++. Try a C++ group. /Thomas -- ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq == 2 of 2 == Date: Fri, Dec 17 2004 5:55 am From: "Luigi Napolitano" ============================================================================== TOPIC: Debugging ANT build scripts http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a174637837f5a523 ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 12:38 pm From: bugbear illusions wrote: > Hello, > I would like to know about the debugging capabilities of ANT. Basically > I have an ANT build script written by a colleague and I wanted to step > through each target to see what are the various tasks that are beings > called. I tried using the -debug option but that output a whole lot of > information without any pause. Could you suggest any other better > method of debugging. If you capture the output of -debug, it's (moderately) readable in a decent editor. Trying to eyeball it as it flys past is futile. BugBear ============================================================================== TOPIC: Commons logging question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/148ce5bb9c7abd0c ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 6:41 am From: "Ryan Stewart" "James Zhou" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, I am working on an application that uses jakarta commons > logging package to log message. Since I put the log4j jar file under > the classpath, I would assume log4j library is used by commons logging. > Here is my question: if I put two log4j.properties config files into > different directories, and both directories are part of classpath, > which log4j.properties config file will be taken? How to debug this > kind of classpath problems? > > Thanks, > The first one that is found. What do you mean "debug"? What is the problem? ============================================================================== TOPIC: Struts Server-Side Form Validation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e8d7503f3780d747 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 6:47 am From: "Ryan Stewart" "timmac" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I do have my RegisterFormBean class extending the ValidatorForm, and > implementing Serializable > > Changing the input attribute of the <action> element doesn't seem to > make any difference. (As an interesting aside, the registration form > example that ships with struts, and seems to work fine, uses > input="input" as I had done, where input is defined as a forward) > > I am very appreciative of all your suggestions... I don't suppose you > know anything else that could be wrong? > > Thanks, > Tim M. > What version of Struts are you using? == 2 of 2 == Date: Fri, Dec 17 2004 5:10 am From: "timmac" 1.2.4 Thanks! ============================================================================== TOPIC: Singleton or static class? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6605e437a9085c2 ============================================================================== == 1 of 3 == Date: Fri, Dec 17 2004 1:57 pm From: Chris Berg I have these options, both works fine, but I wonder which one would be considered more 'correct': 1) // ordinary Singleton pattern public final class MainClass{ private int something; private MainClass instance; private MainClass(){ -- do all initialization -- } public static synchronized MainClass getInstance(){ if (instance==null) instance=new MainClass(); return instance; } public int getSomething(){ return something; } } 2) // static class, no instance public final class MainClass private static int something; private MainClass(){} // never instantiate static{ -- do all initialization -- } public static int getSomething(){ return something; } } Calling getSomething() is simpler in 2); in 1) I always have to obtain the instance first, and I think a virtual method may be more expensive in CPU time - however, 2) does not look very 'object oriented'. Of course, in 1) the instance is an actual Object that can be treated as such, for instance it has toString() etc, but if that is not needed, would 2) be considered 'bad taste', and why ? Normally, you see static methods used for utilities (i.e. java.lang.Math). Chris == 2 of 3 == Date: Fri, Dec 17 2004 2:40 pm From: "Heiner Kücker" Chris Berg > I have these options, both works fine, but I wonder which one would be > considered more 'correct': > > 1) // ordinary Singleton pattern > > public final class MainClass{ > private int something; > private MainClass instance; > private MainClass(){ > -- do all initialization -- > } > public static synchronized MainClass getInstance(){ > if (instance==null) instance=new MainClass(); > return instance; > } > public int getSomething(){ > return something; > } > } > > > 2) // static class, no instance > > public final class MainClass > private static int something; > private MainClass(){} // never instantiate > static{ > -- do all initialization -- > } > public static int getSomething(){ > return something; > } > } > > Calling getSomething() is simpler in 2); in 1) I always have to obtain > the instance first, and I think a virtual method may be more expensive > in CPU time - however, 2) does not look very 'object oriented'. Of > course, in 1) the instance is an actual Object that can be treated as > such, for instance it has toString() etc, but if that is not needed, > would 2) be considered 'bad taste', and why ? Normally, you see static > methods used for utilities (i.e. java.lang.Math). > > Chris > The double locking in your first version is deprecated. Second version is ok. Heiner Kuecker Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de Java Expression Formula Parser: http://www.heinerkuecker.de/Expression.html CnC Template Technology http://www.heinerkuecker.de/Expression.html#templ == 3 of 3 == Date: Fri, Dec 17 2004 2:51 pm From: Stefan Schulz On Fri, 17 Dec 2004 13:57:43 +0100 Chris Berg <[EMAIL PROTECTED]> wrote: > I have these options, both works fine, but I wonder which one would be > considered more 'correct': > > 1) // ordinary Singleton pattern > > public final class MainClass{ > private int something; > private MainClass instance; > private MainClass(){ > -- do all initialization -- > } > public static synchronized MainClass getInstance(){ > if (instance==null) instance=new MainClass(); > return instance; > } > public int getSomething(){ > return something; > } > } It's fine. :) > 2) // static class, no instance > > public final class MainClass > private static int something; > private MainClass(){} // never instantiate > static{ > -- do all initialization -- > } > public static int getSomething(){ > return something; > } > } Also ok. > Calling getSomething() is simpler in 2); in 1) I always have to obtain > the instance first, and I think a virtual method may be more expensive > in CPU time - however, 2) does not look very 'object oriented'. Of > course, in 1) the instance is an actual Object that can be treated as > such, for instance it has toString() etc, but if that is not needed, > would 2) be considered 'bad taste', and why ? Normally, you see static > methods used for utilities (i.e. java.lang.Math). It's mainly a matter of taste. I prefer the first variant, since it is more easily changed into something more object-oriented. Also, such a Singleton can have other uses beyond the static methods. It could implement interfaces, be passed around to other objects, and generally is much more flexible. The overhead of calling getInstance() (or something) is usually really negligable. Besides, you need not use a static initializer, with all the awkwardness involved. (Cause a class load in a static initializer, and you'll be suprised!) -- In pioneer days they used oxen for heavy pulling, and when one ox couldn't budge a log, they didn't try to grow a larger ox. We shouldn't be trying for bigger computers, but for more systems of computers. --- Rear Admiral Grace Murray Hopper ============================================================================== TOPIC: TOMCAT/MYSQL/JSP http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6cfdfa12d76632b1 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 7:11 am From: "Ryan Stewart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > what error r u getting ?? > also connection setting should be > DriverManager.getConnection(connectionURL, "username","password"); > > for ex DriverManager.getConnection("jdbc:mysql://localhost:3306/bfg", > "username","password"); > User and password are not required, and he already said he tried them. == 2 of 2 == Date: Fri, Dec 17 2004 6:04 am From: "atishay kumar" if username n password is not needed, how will the db know which user is trying to connect to the db and does it have access of not ============================================================================== TOPIC: JSTL pages communications http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/25e8e7ed7d7eb6db ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 1:36 pm From: "Carlo" Hi, I have a template.jsp like: <td width="30%"><template:insert parameter="banner" /></td> <td width="20%"><template:insert parameter="menu" /></td> <td width="60%"><template:insert parameter="body" /></td> In the menu page I have some links. When the user click on links I'd like to load different flash animations in the banner page. Example: first link in the menu - load first flash animation in the banner second link in the menu - load second flash animation in the banner and so on It's possible? TIA ============================================================================== TOPIC: How to escape hex digits in a regular expression!!! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3950cae896bde7a4 ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 6:18 am From: [EMAIL PROTECTED] (aefxx) Hi everybody. I just wanted to leave a note on regular expression in java. In one of my projects I had to match hex digits in a string. Say, u want to search for 0x00 in a string, u would likely search for the escape sequence in the API and find "\xhh" with hh being the digits to search for. Well, if done like this u would get an error, being told that \x is not a valid escape sequence. Actually u dont have to escape the x but the backslash. So, it should look like this in the end: "\\x00". This works fine for me. Hope I saved some people some head scratching. c ya ============================================================================== TOPIC: performance of double checked locking http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6881393065d8371a ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 2:19 pm From: Patricia Shanahan Gerald Thaler wrote: > This is just not true. Monitor entry does more: It provides mutual > exclusion. It's impossible to implement this without atomic > read-modify-write instrucions at the machine level. They must lock the bus > and so effekt _every_ processor in the system. Look at the x86 for example: > Monitor entry must execute an instruction like LOCK XADD. This is painfully > slow. For volatile read it suffices that the Compiler/VM doesn't reorder > instructions. This may prevent some optimizations that would otherwise > apply. But other than that there are _no_ performance penalties in the > common code path at all. On x86 volatile reads are way faster than monitor > entry. On other architectures the cost may be somewhat higher. The cost of atomic read-modify-write instructions and the consequences of imposing memory order rules are both hardware dependent. If cache coherence is maintained through e.g. an MESI write-back protocol, atomic read-modify-write only requires locking out of external demands on the executing processor's cache, with the line containing the variable in a modifiable state, for the time it takes that processor to do the complete operation. Hardware memory order rules for multiprocessors are architecture dependent. Rules other than sequential consistency may require extra actions, and delays, to avoid hardware reordering relative to a volatile access. Has anyone published measurements of double checked locking on different multiprocessors? Patricia == 2 of 2 == Date: Fri, Dec 17 2004 9:27 am From: "John C. Bollinger" Gerald Thaler wrote: >>Read the reference material you pointed to yourself. When a thread >>performs a read on a volatile variable, it must (logically) discard its >>local memory and reload from main memory, very much like on a monitor >>enter. This is required by the new semantics of volatile that prevent >>accesses to nonvolatile variables from being reordered with accesses to >>volatile ones in the program order. It may be that a JVM can provide very >>efficient implementation of this requirement, but in that case it should >>be able to provide a similarly efficient implementation of monitor entry. > > > This is just not true. Monitor entry does more: It provides mutual > exclusion. Read or write of a volatile variable must also provide mutual exclusion for the duration of the read or write. The operation might be atomic from the Java perspective (but only if the value isn't a long or double), but nothing can be said about whether or not it could be atomic on unspecified computing hardware. > It's impossible to implement this without atomic > read-modify-write instrucions at the machine level. They must lock the bus > and so effekt _every_ processor in the system. Look at the x86 for example: > Monitor entry must execute an instruction like LOCK XADD. This is painfully > slow. For volatile read it suffices that the Compiler/VM doesn't reorder > instructions. This may prevent some optimizations that would otherwise > apply. But other than that there are _no_ performance penalties in the > common code path at all. On x86 volatile reads are way faster than monitor > entry. On other architectures the cost may be somewhat higher. I am not sufficiently expert on x86 to argue your point about that architecture, but for the same reason I am not prepared to accept your assertions there on your word alone. I am particularly not prepared to accept statements about what certain high-level operations "must" involve at lower levels, especially when JIT is taken into consideration. Consider this, for instance: public class MyClass { private static MyClass instance = new MyClass(); public static MyClass getInstance() { MyClass rval; /* * Written with an inner synchronized block instead of a * synchronized method to avoid any question about what * work must happen within the scope of the synchronization */ synchronized(this) { rval = instance; } return rval; } } I claim that under the new memory model, JIT can safely handle that exactly the same as if variable "instance" were volatile and there were no synchronization. >>>The linked site above gives the following advice: >>> >>>"Instead of double-checked locking, use the Initialize-on-demand Holder >>>Class idiom, which provides lazy initialization, is thread-safe, and is >>>faster and less confusing than double-checked locking." >>> >>>I don't agree. First, the Initialize-on-demand Holder Class idiom doesn't >>>garantee that the Singleton is not constructed until its first use. JVMs >>>have great freedom here. Second, if it does indeed lazy initialization, >>>it can't be any faster than DCL, because it too has to cross at least one >>>read barrier internally. >> >>1) A high-performance JVM will perform lazy initialization if it improves >>performance. Other JVMs are not relevant, nor is lazy initialization if >>it doesn't improve performance. > > > I doubt that. Many VMs will load a class as soon as the control flow enters > a method, that *could* access it: Initialization need not happen when the class is loaded, as long as it happens before the class is used. The loading question is irrelevant because it applies equally to a DCL scenario. On the other hand, modern VMs generally do delay initialization. [...] > The VM cannot decide wether my static initialization is expensive or not. It could apply simple heuristics to come to a reasonable first-order guess. There are other possibilities too. I flatly refuse to accept your unsupported assertion. >>2) Initialize-on-demand can be significantly faster than DCL on a volatile >>variable, because after initialization (of the _final_ variable) no read >>barrier need be crossed to access it. > > > There must be a read barrier somewhere. Why? If the variable is final then I see no need for a read barrier. All reads, forever, will return the same value, regardless of the actions of any other threads. Even if the read is not atomic. Even on a multi-CPU system with multiport memory and no cache coherency support. A thread could even safely cache a copy of the value and use that as long as it liked. John Bollinger [EMAIL PROTECTED] ============================================================================== TOPIC: Reading HTML contents from the server http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2f868e582b49802 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 6:21 am From: "milkyway" Hello all, Is this possible 1. Create a table in HTML 2. Through javascript add and delete items to the table (have already done this) 3. Hit the save button and pass the contents of the table to the server. Are there any examples out there where the table contents are being passed to the server? How can one do this? I am basically looking to pass such contents to a bean (i.e. 1 'get' statement would fetch all of the items in the HTML table). Kindest Regards. == 2 of 2 == Date: Fri, Dec 17 2004 2:32 pm From: "Dag Sunde" "milkyway" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello all, > > Is this possible > 1. Create a table in HTML > 2. Through javascript add and delete items to the table > (have already done this) > 3. Hit the save button and pass the contents of the table to the > server. > > Are there any examples out there where the table contents are being > passed to the server? > > How can one do this? I am basically looking to pass such contents to a > bean (i.e. 1 'get' statement would fetch all of the items in the HTML > table). > This is really a JavaScript question...: Just as you put the values into the table cells with JavaScript, write a JavaScript function to extract the values from the table cells and build a (ie. semicolon/Cr separated) string from them. document.getElementById("cellId_N"); Now put this string into a hidden form-field, and submit the form .form.doSubmit(); -- Dag. ============================================================================== TOPIC: Strategy & Delegation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b71cbc628cc61da ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 4:11 pm From: Markos Charatzas I'm trying to get my head around this... Assume 3 Interfaces Request:Interface +getQuery():String +getResults(Inquirer):List Inquirer:Interface +getExecutive():Executive +getResults(Request):List Executive:Interface +getExecute(Request):List And 2 Base classes class BaseRequest { List getResults(Inquirer inq) { ing.getExecutive().execute(this); } } class BaseInquirer { Executive exec; BaseInquirer(Executive exec) { this.exec = exec; } ... List getResults(Request req) { req.getResults(this); } } Let's say we would like to add an extra interface which extends Request, therefore ServiceRequest:Interface +getServiceName():String However, making a new interface for Executive -> ServiceExecutive:Interface +getExecute(ServiceRequest):List We have to sacrifice the functionality in BaseRequest class of the method getResults(Inquirer) So what do we do? Do we just have a ServiceExecutive interface that although extending Executive, it does not provide any additional methods so that forces to check every Request passed using instanceof. Of course there will be some drawbacks, but is this common practice to this problem? Thanks for your input ============================================================================== TOPIC: Algorithm, please help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8bcd7defb3cda029 ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 2:35 pm From: "John B. Matthews" In article <[EMAIL PROTECTED]>, Sudsy <[EMAIL PROTECTED]> wrote: > HS1 wrote: > > Hello all > > > > I have a vector that store answer objects. Each object has a question number > > and answer value that can be presented as following: > <snip> > > Part of the joy of programming is discovering how best to approach > a problem. It takes a lot of experience as well as an analytical > mind. > > Reaching out to a ng each time you encounter a problem is not going > to help anyone. The op isn't learning when solutions are provided > on a platter and the resident gurus aren't likely to provide a neat > package, wrapped with bows, when the op hasn't even made the slightest > effort to help his/herself. Although I offered the OP somewhat more specific guidance, I agree with you. > Either you have the ability to see solutions to obvious problems or > you don't. In the latter case, you're not likely to advance very far > in the industry. In particular, one solution called for indexing an array by some element of the problem, e.g. look-up table, cross-table etc. I find it a challenge to students in many languages. > If you (the op) want to test your mettle, I highly recommend the > following site: > <http://www.topcoder.com> > Enter the time-constrained competitions and see how you do. If > nothing else, you'll have the opportunity to see how some "real > smart cookies" approach the problems posed and can learn something > about programming. > Just remember that you'll have others trying to "poke holes" in > your submitted algorithms and the challenges will often succeed > if you don't take into account what we call the "end conditions"! > > Heck, it can make you a better programmer! Or perhaps it might > suggest that you find another calling... :-( -- John jmatthews at wright dot edu www dot wright dot edu/~john.matthews/ ============================================================================== TOPIC: Aw Ma - Do I *have* to use tags? ;-( http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9fcfc4eec9ac055f ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 9:40 am From: Sudsy milkyway wrote: > Hi Sime, > > Thank you for responding ;-) > > If one does not have to use html tags, then (sorry if this has already > been asked before) why use them at all? <snip> They handle certain situations well. I'm thinking in particular about such things as URL rewriting when the client doesn't support cookies. Even the html:html tag does more than just generate the html tag... ============================================================================== TOPIC: timout on line of code http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/85ddb5609baca4a0 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 2:55 pm From: "Ike" If I have a URLConnection uc, I would like to permit the following line of code to execute in say, ten seconds: InputStream inputStream = uc.getInputStream(); If something is wrong on the server, this line of code hangs, and I'd like to catch it after, say ten seconds, and have it segue to another line of code. How do you do that? -Ike == 2 of 2 == Date: Fri, Dec 17 2004 4:06 pm From: Stefan Schulz On Fri, 17 Dec 2004 14:55:41 GMT "Ike" <[EMAIL PROTECTED]> wrote: > If I have a URLConnection uc, I would like to permit the following > line of code to execute in say, ten seconds: > > InputStream inputStream = uc.getInputStream(); > > If something is wrong on the server, this line of code hangs, and I'd > like to catch it after, say ten seconds, and have it segue to another > line of code. How do you do that? -Ike Normally, the connection attempt will time out on it's own. You could put it off to another thread, and interrupt the thread if it has not finished after some set time limit (I'm not sure this will work, but it is the only idea i have right now), but you can not directly specify such a timeout. -- In pioneer days they used oxen for heavy pulling, and when one ox couldn't budge a log, they didn't try to grow a larger ox. We shouldn't be trying for bigger computers, but for more systems of computers. --- Rear Admiral Grace Murray Hopper ============================================================================== TOPIC: Java and inlining http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b13dd1cb6d5e4bd0 ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 7:19 am From: "Aaron Fude" Hi, Is there a good article to read about the inlining of functions in Java. For example, how inefficient would it be to write double sum(double x) { return Math.sin(x) + Math.cos(x); } Thanks! Aaron Fude ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
