Jon Dornback

Ranch Hand
+ Follow
since Apr 24, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jon Dornback

I clicked on the "2 public classes in the exam" topic in the scjp forum and got the following error message:


I waited a bit and refreshed the page and it worked fine. Thought you might like to know.
21 years ago
I had the misfortune of using aol for awhile (suckered in by the free trial after moving and having no other net access). Then I set up a linux box on a hub, and couldn't get the two boxes to even ping each other. I poked, prodded, reinstalled drivers, anything possible to see where I went wrong configuring the linux box. Eventually I realized that aol had installed a WAN adapter on the win2k box that snagged every packet and flung it off to the aol servers. even things marked for 192.168.whatever went straight to aol, no choice in the matter. I quickly ditched aol. just one more gripe against them.
ps - if you want some nerdy fun, try explaining to an aol rep that their product is taking every ethernet packet from my class C subnet...
21 years ago
that is definitely worth knowing - I never would have noticed that otherwise. everytime i think i'm ready for the exam, i find out something like that and it ruins my confidence!
you're using the same algorithm I would use. If you need a re-sizable array, use java.util.ArrayList (don't use Vector - most of what i've read warns against it). To put ints in to the ArrayList, use this in the tokenizing loop:
21 years ago
I'm probably over-thinking this, but am hoping someone can shed some light on how this works. The notify() method must be called from within a sync block (because the monitor for that object must be owned by the calling thread). I'm ok with how the wait/notify process works, but am confused on this point: if notify() is called from within a sync block, how does another thread gain access to the locked object?

usually the call to notify is the last statement in a sync block, like the one above. I assume in this scenario that the sync block exits and then another thread is notified and starts to run. but what happens if notify is called before the end of the block?

in the above snippet, what happens? the API for notify does not specify that notify() releases the lock. does that mean that a thread wakes up, tries to get the lock, but since the current thread is still in the sync block the contending thread gives up and goes back to waiting? or does it stay in some sort of contending-limbo until the sync block exits?
i think what this probably comes down to is when does the notify actually happen? right at the time the call to notify() is made? or does the JVM hold off notifying a thread until the sync block exits?
sorry for the thousand question marks - it's just one of those finer points that i probably need not worry about but it's bugging me.
-Jon
Where in the API does it say that only the LinkedHashMap specifies that behavior?
In any case, the LinkedHashSet API also specifies last-accessed order. Maybe LinkedHashMap is the only *Map* collection that supports last accessed functionality.
reasonScroller.getVerticalScrollBar().setValue(reasonScroller.getVerticalScrollBar().getMinimum())
or with aptly named variables:
JScrollBar scrollbar = reasonScroller.getVerticalScrollBar();
int min = scrollbar.getMinimum();
scrollbar.setValue(min)
21 years ago
it's perfectly legal to have a code block within a code block. i don't think it is commonly used, but the main effect is to limit the scope.
the code below shows an example of how it works:
you can't get more than one ServerSocket to listen on a single port: you will get a BindException every time. (see example below) I don't think this is possible in other languages either, though i could be wrong.
UDP is be nature and definition unreliable. there is no guarantee whatsoever that the information will reach its destination. Don't use UDP for anything critical.
HTTP is sent over TCP connections. You might want to google search for a tutorial on TCP vs UDP connection types, and then see how HTTP fits in to that scheme.
I can't help you much with the assignment because there are too many questions: what clients are you trying to respond to? if they are HTTP clients (like browsers), then why not give them over to the webservers directly? if they are some other type of client (telnet or ftp or something else entirely) then will they be able to use port 80? if the clients aren't using HTTP, what protocols will they be using? the program listening on port 80 will need to know what each protocol looks like and where to send it, which may prove very tricky indeed. those are some things to get you started thinking about what the program will need to deal with.

[ July 22, 2003: Message edited by: Jon Dornback ]
21 years ago
what value are you using in the setValue(int) method? the scale is not always from 1 to 100: use getMinimum and getMaximum to determine what the range is.
21 years ago
i haven't found this listed elsewhere, and am wondering what you are allowed to bring in to the exam with you. Just you and your brain? Or can you bring/or be provided with scratch paper? Some of the questions on the mock exams are easier for me to work out if I can write a few things down - particularly the ones involving math operators.
Speaking of math operators, how difficult are the operator questions on the real exam? In one mock exam, questions over things like "result of -1 >> 400" seem difficult at first, but turn out to be simple if you know that -1 >> anything is -1. Is the real exam any more difficult than that? If so, I hope calculators are allowed...
you can also create a shortcut to it. in explorer, create a new shortcut. edit the properties so that the command is the path to java.exe or javaw.exe followed by your class name and any other arguments. you can also use the environment variables if they are set:
%JAVA_HOME%\bin\java.exe MyApp param1 param2
then, edit the "start in" box so that the path is the directory of your app. you should then be able to double click on it and launch the program.
21 years ago
most of the java APIs have started using array of chars instead of String objects whenever security is concerned. If you look at the javax.crypto and java.security packages, many of those methods are the same. The reason (as I remember/interpret it) is that Strings are interned and more prone to security problems than an array of chars that will be garbage collected.
If you were actually using the password, the return type of char[] can be sent directly as the parameter to unlock a private key and other methods, no String needed.
21 years ago
that was precisely it. i read the sun tutorials that said the same thing. I updated the code so that the scroll pane is adjusted in a thread that is handed over to the invokeLater method, and it seems to have cured the problem.
thanks for the help and pointing me in the right direction.
21 years ago