Tad Dicks

Ranch Hand
+ Follow
since Nov 16, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tad Dicks

I've been given the task of being a maintenance programmer and so I've inherited a large amount of code. I'm fairly certain I know the answer to this question, but the original programmers are not here to ask so...



log is an instance Logger. Is there any point in the enclosing if statement? I'm fairly certain the obvious answer is no, but it seems so obvious to me that I'm wondering if I'm missing something.

Removing the surrounding if statement shouldn't have any effect on the program? (other than trimming size and possibly speeding up the application depending on how often this code is executed, unless the javac removes the extra check during optimization anyway anyhow).

Note that Head First Design Patterns does specifically say that the pattern only works if the variable is volatile, and only in JDK 5 or later.



I read through most of the book several months ago and was going from memory... I did a quick search and found a link to the code. I will admit I was just looking for a code snippet that matched what I remember reading in the book. My bad.

I'm going to blame it all on the .NET programming I've been forced to do for the last 6 months.
14 years ago
Thank you for the link.
14 years ago
Hrm... I haven't seen it mentioned here, but I did read that pattern in the Head First object patterns book and a quick search brought up the pattern on an IBM site.

Well I'm glad I posted erroneously, otherwise I would have never known. I guess I will go look for the thread that explains why this doesn't work.
14 years ago
You could also look at the double checked singleton:



This keeps down the overhead of instantiating an object that might never be used/needed and only performs the relatively more resource expensive synchronized method a single time.
14 years ago
That makes sense and I know Sun has done a lot of work to make sure each release is backwards compatible with previous versions, but I know it isn't always.

I guess I always thought it would be nice if there was a mechanism for specifying. I guess writing batch/or script files that specify which version to use. Maybe I should be looking into JNLP? Looking at the Java Control Panel (at least on a windows machine), I can open a window that will list all of the Java Runtime Versions installed on the machine (along with their paths). Each different product (Full release number e.g. 1.5.0_02 or 1.4.2_04 etc) has its platform (1.5 or .14 in my case) and a checkbox for enabling (multiple platforms/products are enabled).

So obviously Sun has created a mechanism for keeping track of different Runtimes installed on a machine. Is this mechanism only available to JNLP/Webstart programs or am I assuming to much here, and isn't even available for webstart applications?
14 years ago
Something like?

I think this may only work with Java 5 and the autoboxing/unboxing.
Otherwise this should work:
14 years ago
I know its possible to install multiple JRE on a single computer.
Is there any easy way when you create an executable Jar file to specify which one you should use? Or will it always use the one the JAVA_HOME environment variable is pointing too?

Is there any simple solution to managing multiple JVM's for multiple applications? If x application needs Java 1.4 and y application needs Java 5?

Any help or links to a howto/explanation are greatly appreciated.
14 years ago
No, one's an intel chip(p4 2.6ghz) and the other is an amd (XP 2900). On the intel chip I've never seen any java application use more than 50% of the processor (its like there is a limit), but not so on the amd machine. Both are running Windows XP sp2. Just seems odd to me.
14 years ago
I've done a bit of java programming, I've never touched any j2me stuff. I know nothing about it, but I finnally got a cellphone that actually has graphics/games that are "powered by java".

I have absolutely no clue as to how to go about installing custom software onto a cellphone (or if it is even feasible for an enduser to do that).

I guess I don't even know where to begin looking... and am wondering if anyone here could point me in the right direction.

any help is appreciated.
14 years ago
I figured making the thread sleep would be the best way to regulate the speed of the game.

I just don't understand (and I guess this isn't obvious and probably platform/jvm specific) why on one machine the jvm would take full control of the cpu and on another machine be throttled to only using 50% of the cpu. Especially when they're both the same OS and afaik same jre (1.5.06)
14 years ago
check out:
small java games

There are some really small games (code wise) that might be useful while trying to learn java (with the goal of developing a game). You'd be suprised what someone can put together in a day. An mmorpg would be a lot of work. Just start on the rpg part... that'll be a lot of work in and of itself.
14 years ago
what seems strange (to me at least)
after doing this:


The out put is:
o and oo are different objects
o and oo are different objects
o and oo are same objects
o and oo are different objects

I would have expected the same results from your code.. but merely passing them to a method caused them to get their own references?

-Tad
Why not just make a "World" object that holds all the "room/location" objects and then contains a "map" of what rooms are connected and how. Then each room can hold other game objects (npcs/items etc).
14 years ago
I decided to make a simple arcade game. In the main class I have a "while(true)" loop and inside of this loop it redraws the screens listens to keystrokes etc. I would assume this is fairly typical. I just want to know why when I run the game on one machine it uses almost 100% of the CPU and on another machine it only uses 50%. The only differences I can think of is one is an AMD and the other is a Pentium, both are running windows XP professional. Both machines are running Java 1.5. I haven't put anything into to regulate the fps, and am assuming this means it uses as much of the cpu as its being allowed too. On the first machine I do want to slow it down a bit, but on the second machine... I think I'd rather make it go a little faster. I'm guessing to slow it down I just need a timer and to have it only redraw the screen after X amount of time, as for speeding it up I have no clue where to start.
14 years ago