Landon Blake

Ranch Hand
+ Follow
since Dec 04, 2003
Merit badge: grant badges
For More
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 Landon Blake

It looks like I'm not the only one having a problem with a bug that causes the ConcurrentModificationException, but I didn't want to high-jack Tom's thread.

I'm trying to track down a ConcurrentModificationError. I've got some code that uses separate threads to iterate over a single Java Collection. The tricky part is during the iteration an object that implements the Runnable interface is created and sent to the AWT Event Dispatching Thread. Someone told me that this code can't be the source of the exception becuase the actions encapsulated by the objects implementing runnable are executed seqentially on the AWT Event Dispatching Thread. Therefore, the Java Collection couldn't be getting modified at the same time.

Here is my question. The code that actually iterates over the collection appears outside of the AWT Event Dispatching Thread. This means that the Java Collection could be interated over by 2 separate threads at the same time, although in this case we aren't "modifying" the actual objects stored in the collection, or the order of the objects in the collection.

Can the act of iteration over a collection by multiple threads cause the ConcurrentModificationException, or do the threads have to actually change something about the collection or the objects it stores?

Thanks,

Landon

P.S. - Here is the applicable section of the Javadoc for ConcurrentModificationException:

Note what the Javadoc for the ConcurrentModificationException thread states:

"it is not generally permssible for one thread to modify a Collection while another thread is iterating over it. In general, the results of the iteration are undefined under these circumstances. Some Iterator implementations (including those of all the collection implementations provided by the JRE) may choose to throw this exception if this behavior is detected."
17 years ago
Thanks Jeff.

I think I need to create a "default" executable that accepts "default" JVM arguments.

I'll also provide a script that can be modified by more advanced users that want to tweak the JVM arguments.

Thanks for your help.

Landon
17 years ago
I'm trying to find an easy way for my users to launch a Java program on the Microsoft Windows operating system. I wanted something a little more user friendly than a batch file.

I took a look at JSmooth, which is exactly what I need, but it doesn't seem to have a way to permit "dynamic" command line arguments for the JVM. (For example, with a batch file I can read the command line arguments for the JVM from a text file.)

I had thought about writing my own application launcher as a separate Java program. This launcher program would have a simple GUI that would allow the user to select the start-up options, and would then use the runtime.exec() method to launch my main application.

I am wondering how other developers handle this situation. Is there a better solution that I am missing?

Landon
17 years ago
I'm working on a parser for a binary file format. I'll be getting ints from the Java reader that represent the values of each byte in the file being parsed. Many of these bytes represent ASCII text. I'm looking for the best way to:

[1] Convert a single int representing the value of a byte read from the binary file into a char or String that represents the corresponding ASCII value.

[2] Convert a group of ints representing the value of a series of bytes read from the binary file into a single String.

I think I can do #1 using the toString() method of the Byte class. Is this the best way? How would I accomplish number 2?

Thanks for the help.

Landon
17 years ago
Is there a Java class that provides a method to convert a string to the appropriate numeric data type (int, float, double) based on the contents of the string. (Whether the String contains a decimal point and the number of digits.)

I can write this logic from scratch, but want to use the "standard" way to do this, if there is one.

Thanks,

Landon
17 years ago
Thanks for all of the help guys. What you said makes perfect sense. I'll see about overiding the hashcode() method on those custom objects of mine.

Landon
17 years ago
I've been chewing on this problem some more. After reading the responses I received, I think I need to try and detect any character or combination of characters that are specified in the XML specification.

Does this sound right?

Landon Blake
17 years ago
I'd like to thank all of the posters for their comments. They've helped me realize that this is a little trickier than I thought it was.

I'll post to an XML developers list that I subscribe to. Perhaps they'll have some suggestions on the best way to handle this. I may have to get back to you guys on some help with implementing the solution.

Thanks again.

Landon
17 years ago
I'm probably overlooking a reaaly obvious way to do this.

I've got a method that accepts a java.awt.Image as an argument and calculates the center point of the image.

I noticed the getHeight() and getWidth() methods of the Image class require that an ImageObserver be passed as an argument. In my case I don't have an ImageObserver to pass, and it doesn't really make sense to create one just for this method. I could create an javax.swing.ImageIcon object from the Image and then just call getIconHeight() and getIconWidth() but I wanted to check with you guys so that I could make sure that I wasn't overlooking something easier.

Landon
17 years ago
Both NetBeans and Eclipse offer a mechanism to update "plug-ins" or "modules" from the web.

This concept has intrigued me, and I would like to implement something similar in my own programs. I'm thinking of something that would read a text file on a webserver to check for updates to my program or its plug-ins.

However, I've never done anything like this, and I'm not even sure what classes I would start to look at. I gues my first questions would be:

[1] Is there a "standard" way to implement this type of functionality?
[2] How do I access a text file that resides at a URL, such as a web address?
[3] How do I download a JAR from the web and execute its main method from within a running Java application?

Thanks,

Landon
17 years ago
Yes it does help.

Thank you for the response to this post, and my other related post.

Actually, another Java developer told me that the repaint() method will take a clip boundary as you mentioned.

Thanks,

Landon
17 years ago
Paul,

I think you have answered my basic question about memory usage. It may sound like I won't be able to represent roads and parcels with this type of object, but I will. :]

I'll just access the member data from the hard disk instead of from RAM.

Thanks for your help.

Landon
17 years ago
Jeroen,

I assure you it is not the second case. The first case you mentioned may apply in some circumstances.

I'm working on a CAD workstation, so the size of the RAM on my computer is no the issue.

The program is a GIS/CAD program, and oftentimes creates bojects to represent hundreds or thousands of road segments and parcel polygons. This data can get very big, very quickly.

Do you think my idea of an object with no member variables work?

Landon
[ August 24, 2006: Message edited by: Landon Blake ]
17 years ago
I am working on a program that creates hundreds, if not thousands, of objects in memory. This often causes the program to run out of memory and shut down.

I am looking for a solution to this. I am curious how much memory is required from objects that belong to a class that has only method definitions, and no member variables or other objects included in its definition.

I want to know if I can solve my memory problem by creating an object that accesses its "data" or member variables off of the hard disk instead of from RAM. I know this will impose a serious speed or performance penatly. However, if this will work I can take some steps to get around the speed problem.

Will I reduce RAM usage by creating hundreds or thousands of objects from a class that only contains method definitions?

Thanks for the help.

Landon
[ August 24, 2006: Message edited by: Landon Blake ]
17 years ago
I am working through the design of a disp[lay for a CAD/GIS program written in Java. (I haven't decided firmly if I will use SWT or Swing.)

This program will have to display a large number of Java 2D Shapes. I'm want to make the rendering process as quick and efficient as possible. I had a couple of questions about how I can do this. I will ask the second question in this thread:

My program will allow the user to select shapes on the display using various interactions with the mouse, and will subsequently allow them to move or modify those geometries. Is it possible to only render the portion of the canvas that needs to be repainted, instead of repainting the entire canvas everytime a single shape is modified? Would I do this by splitting my display into a grid of different images, or can I just pass the rectangular bounds of the new area that needs to be rendered?

Is this method of partial rendering possible? Any ideas or suggestions on how I can learn the techniques I need to implement it?

Landon
17 years ago