Jim Hoglund

Ranch Hand
+ Follow
since Jan 09, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
8
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 Jim Hoglund

I interested in the current grading delay. So, if you received your assignment grade
in November, how long did you wait after your submission? (I'm at 4-weeks.). Also,
in your opinion, what is the best way to meet the "live" course requirement? Thanks.

Jim ...

Randall: As you have seen, questions posted on JavaRanch can be quite specific and finding
answers in your program (even if it is well documented) may be too difficult for someone
struggling with a particular problem. Maybe it would work better to use your program as
a library of examples that you can pull from and post as part of your answer to someone's
question. What do you think?

Jim ...
7 years ago
Gianni: This is an interesting question. It would be helpful to know
why you need this information. Can you explain further?

Jim ...
7 years ago
Okay, the Preferences API is a good solution, but the problem as stated asks for much less.
Form-follows-function, in this case complexity-follows-need isn't a bad rule to follow, so I would
still do a simple file approach. It doesn't seem that "do[ing] a lot of fancy things real easy" is
part of the requirement. As to doing a lot of open/close work, it's pretty basic stuff - just a few
lines. Plus there's no studying required to make sure that Preferences is used correctly.

Jim ... ...
8 years ago
What do you want to do with the displayed date/calendar after it has been displayed?

Jim ... ...
8 years ago
It seems that Preferrences or Properties are both overkill unless there are
additional persistence needs. You might consider just reading a file on start-up
and writing to it each time the value changes. Be sure to close the file after
each read/write. Job done, and completely crash proof.

Jim ... ...
8 years ago
If you don't need to change anyTypeArray (below) as you scan
through it (add, delete, etc.), a further improved version is:
Jim ... ...
8 years ago
No - all access to an object must be synchronized. What is called
a "dirty read" can occur if a read operation is allowed while a write
operation is in progress.

Jim ... ...
Your data structure choice depends on size and dynamics (add, find, remove, etc.)
that you don't describe. As for synchronization, all users of a referenced item must be
protected from untimely changes to that item. So if user37 reads or updates the object
referenced by Key1, user37 must synchronize on that object, not the entire data structure.
In addition, users that use or change the data structure must synchronize on it.

Jim ... ...
Excellent !
Jim ... ...
8 years ago
How about:
Jim ... ...
8 years ago
I usually do it this way. Hope this helps.

Jim ... ...
8 years ago
If your singleton has no constructor you will access it statically, like:
MyClass.getInstance(). Loading MyClass kicks off the static code blocks
and other member inits. They are run in order, from top to bottom. This
would include initializing the object to be returned by getInstance(). So
there can be no race condition because building the object to be returned
will complete before the return occurs. Does this help?

Jim ... ...
How about setting the timer to a 5-second interval?
Then you can run your process every time it wakes up.
Am I missing something?

Jim ... ...
8 years ago
Yes, you're on the right track. If the Set is sorted on Integer, you can
just look for a missing value to find the end of a range. Give it a try.

Jim ... ...
8 years ago