Not leaving a method until a Thread has finished

J

james

I would rather you stopped insulting me in this way. I took your
comments on board and implemented my code in the was you suggested.
Suffice it to say that it didn't work whether that be due to a poor
explanation or it not extending to the complex situation in which I am
trying to implement it.

I am more than willing to consider (and have considered) any post here
otherwise I would not have asked the question in the first place. Just
because you have something against the FoxTrot project does not mean it
is of no use. If exactly the same results can be achieved through 5
lines of code why would that have undertaken this project.

As for you comment that it uses "some interfaces which Sun most likely
accidentally left open" I don't know that you can make this statement
unless you work for Sun which I doubt you do.

Anyway I do not feel you post added anything to the topic and if you
"chalking it up
as a lost cause" means no more posts here from you that sounds like
good news to me.

Thanks again.
 
S

steve

Why is that a bad thing? If the tool works, and has no bugs, why should
they make any changes to it?

It is a simple concept, presumably well-executed. Once it is finished,
what more needs to be done? Why should there be any more releases?

Rogan

the problem i have with it :
1. is that by their own admission it's taken them 2 years to add a couple of
new interfaces.

2. There is a lot of software out there written in java that DOES NOT USE IT,
doing exactly what the author wants to do, maybe the poster needs to look at
his coding and thought processes.

3. what amazes me most is that people are always saying java is "bloated",
and yet they think nothing of adding a several thousand line library to do
something that is easy to accomplish, in a lot less with a little thought.

there are some very good useful libraries out their but FoxTrot is not one
of them.

it's a hack guys , and using hacks no matter how clever they are , is a very
good way to write bad software.
 
S

steve

I would rather you stopped insulting me in this way. I took your
comments on board and implemented my code in the was you suggested.
Suffice it to say that it didn't work whether that be due to a poor
explanation or it not extending to the complex situation in which I am
trying to implement it.

I am more than willing to consider (and have considered) any post here
otherwise I would not have asked the question in the first place. Just
because you have something against the FoxTrot project does not mean it
is of no use. If exactly the same results can be achieved through 5
lines of code why would that have undertaken this project.

As for you comment that it uses "some interfaces which Sun most likely
accidentally left open" I don't know that you can make this statement
unless you work for Sun which I doubt you do.

Anyway I do not feel you post added anything to the topic and if you
"chalking it up
as a lost cause" means no more posts here from you that sounds like
good news to me.

Thanks again.

look if you really want to do this try the following, it's a hack but there
you go.


public void jbInit(){
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(new BorderLayout());
this.setTitle("Simple Test");

JButton jb = new JButton("Go Task");
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
goTask();
While( notification==false){
sleep(1000); // or what ever
}
System.out.println("I don't want to get here until the thread t
has finished.");
}
});
this.contentPane.add(jb, BorderLayout.CENTER);
}


public void goTask(){
notification=false;
Thread t = new Thread(new Runnable() {

public void run() {
for(int i=0;i<10;i++){
try{
Thread.sleep(500);
}catch(Exception e){
e.printStackTrace();
}
}
System.out.println("About to finish Thread");
notification=true;
}
});
t.start();

System.out.println("This needs to be done seperatly to the
thread.");


}

or make your goTask a class, and extend it with a method called
"IsTaskfinished()"
and just have a call in you main program
While( IsTaskfinished()==false){
sleep(1000); // or what ever
}
 
R

Rogan Dawes

the problem i have with it :
1. is that by their own admission it's taken them 2 years to add a couple of
new interfaces.

But if new interfaces were not needed until then, is that a problem?
2. There is a lot of software out there written in java that DOES NOT USE IT,
doing exactly what the author wants to do, maybe the poster needs to look at
his coding and thought processes.

I think that the comments about visual code flow seemed to be
reasonable. I think that the "dialog.show();" analogy is fair. You
expect that the code will resume only after the dialog has been closed.
Similarly, you expect that your code will only continue after the time
consuming task has completed.
3. what amazes me most is that people are always saying java is "bloated",
and yet they think nothing of adding a several thousand line library to do
something that is easy to accomplish, in a lot less with a little thought.

there are some very good useful libraries out their but FoxTrot is not one
of them.

it's a hack guys , and using hacks no matter how clever they are , is a very
good way to write bad software.

The only really good/compelling argument that I have seen against
Foxtrot is the fact the Sun might change the way that event handling is
done at some point, and then FoxTrot will break.

That by itself is enough to convince me not to try it myself. For the
record, I use SwingWorker in my own code, but was thinking of trying
FoxTrot . . .

Regards,

Rogan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,108
Latest member
AlbertEste
Top