L
Luc The Perverse
In reviewing my post, I have realized that I included a lot of superfluous
information. To allow you to quickly find the most condensed version of my
question I will put it between two rows of asterisks.
Well I've gone from only having done one program in Java with general
contempt for the language a few months ago, to absolutely loving the
language. I've done over a hundred algorithm implementations in Java at
Topcoder improving both my understanding of the semantics of the language
and my algorithm solving skills (which may or may not be algorithm
independent).
I have made a working VERY rudimentary java program which works like this.
1. It starts a thread to begin collecting names of media files.
2. It loads up a Form from which you can search
public static void main(String[] args) {
final FileList theList = new FileList();
BackgroundListPopulator mysearch = new
BackgroundListPopulator("d:\\My Music", theList); //Note: change hard
coded path to be compiler line option
mysearch.start();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI(theList);
}
});
I generate a FileList object which the compiler told me had to be final
to be used in the inline class. BackgroundListPopulator is my Thread
derived class which searches for all files and puts them into a giant linked
list. It sets a boolean in theList object to signal when it has completed.
The code after that is cut and pasted from a GUI tutorial on the Sun
website. While I understand in theory what the invokeLater function does -
I do not see why I need to do this - it seems to complicate matters. I am
pretty sure I have made GUIs before without this :"protection"
There is a lot that I don't like about this. First - it seems like it
should be easier to get data to the search form. Creating a final in this
instance works - but that is not always going to be the case.
********** The question *********
My mutex is just a boolean. Right now if the boolean is false when the
search button is clicked, I simply display "not ready" in the JList box. I
would like to use true mutex and have the search display as soon as the
results are available - but I know I cannot block in the UI thread. What is
a good way to go about this?
*********************************
I decided to give eclipse and netbeans a try - but netbeans quickly
stole my heart as I was able to quickly draw a beautiful form - which is all
I really want an IDE for anyway. Compared with the ridiculously ugly GUI
my first draft program had, this was a notable improvement. I need to read
up and google some more - I don't know how to reference a public class found
in another file. I thought you could just call it by name, but NetBeans got
mad when I tried to draw the form I had just made. I will figure that out
though.
Just a side note: Search results are virtually instantaneous. The
start time even for a first instance of the JVM is less than the amount of
time that the windows dog dances for. I compiled my code in a trial version
of excelsior and I was able to get my start time down to near a second (not
actually measured, just watching)
information. To allow you to quickly find the most condensed version of my
question I will put it between two rows of asterisks.
Well I've gone from only having done one program in Java with general
contempt for the language a few months ago, to absolutely loving the
language. I've done over a hundred algorithm implementations in Java at
Topcoder improving both my understanding of the semantics of the language
and my algorithm solving skills (which may or may not be algorithm
independent).
I have made a working VERY rudimentary java program which works like this.
1. It starts a thread to begin collecting names of media files.
2. It loads up a Form from which you can search
public static void main(String[] args) {
final FileList theList = new FileList();
BackgroundListPopulator mysearch = new
BackgroundListPopulator("d:\\My Music", theList); //Note: change hard
coded path to be compiler line option
mysearch.start();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI(theList);
}
});
I generate a FileList object which the compiler told me had to be final
to be used in the inline class. BackgroundListPopulator is my Thread
derived class which searches for all files and puts them into a giant linked
list. It sets a boolean in theList object to signal when it has completed.
The code after that is cut and pasted from a GUI tutorial on the Sun
website. While I understand in theory what the invokeLater function does -
I do not see why I need to do this - it seems to complicate matters. I am
pretty sure I have made GUIs before without this :"protection"
There is a lot that I don't like about this. First - it seems like it
should be easier to get data to the search form. Creating a final in this
instance works - but that is not always going to be the case.
********** The question *********
My mutex is just a boolean. Right now if the boolean is false when the
search button is clicked, I simply display "not ready" in the JList box. I
would like to use true mutex and have the search display as soon as the
results are available - but I know I cannot block in the UI thread. What is
a good way to go about this?
*********************************
I decided to give eclipse and netbeans a try - but netbeans quickly
stole my heart as I was able to quickly draw a beautiful form - which is all
I really want an IDE for anyway. Compared with the ridiculously ugly GUI
my first draft program had, this was a notable improvement. I need to read
up and google some more - I don't know how to reference a public class found
in another file. I thought you could just call it by name, but NetBeans got
mad when I tried to draw the form I had just made. I will figure that out
though.
Just a side note: Search results are virtually instantaneous. The
start time even for a first instance of the JVM is less than the amount of
time that the windows dog dances for. I compiled my code in a trial version
of excelsior and I was able to get my start time down to near a second (not
actually measured, just watching)