Problem with thread
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi!
I want to run some kind of loading (refreshing text) while programs works in background.
I'm tried with thread but it not works propertly.
This is my algorithm:
1. enter data
2. start loading thread
3a. if data OK stop loading thread and show result
3b. else stop loading thread and return to 1
Thread in run method have infinity loop "while(true)". I stops thread with thread.inrerupt();
Problem is when i enter wrong data second time. When enter data second time thread first stops and then starts! (but first is called start).
I know that threads can do this but how can i solve this?
Thanks!
I want to run some kind of loading (refreshing text) while programs works in background.
I'm tried with thread but it not works propertly.
This is my algorithm:
1. enter data
2. start loading thread
3a. if data OK stop loading thread and show result
3b. else stop loading thread and return to 1
Thread in run method have infinity loop "while(true)". I stops thread with thread.inrerupt();
Problem is when i enter wrong data second time. When enter data second time thread first stops and then starts! (but first is called start).
I know that threads can do this but how can i solve this?
Thanks!
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I don't think we can help you without some (relevant) code.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Milan Djukic
Greenhorn
Posts: 27
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Sorry for late answer.
Here is thread:
Button listener (ActionListener)
Here is thread:
Button listener (ActionListener)
Milan Djukic
Greenhorn
Posts: 27
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I solved this but this is stupid way.
I just sleep client for 100 miliseconds like that:
Whay now works?
I just sleep client for 100 miliseconds like that:
Whay now works?
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I think you're trying to re-invent the wheel. Look at the classes in the java.util.correct package.
With a Future you can complete background tasks in a much cleaner way.
With a Future you can complete background tasks in a much cleaner way.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
posted 14 years ago
You mean java.util.concurrent, right?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Wouter Oet wrote:Look at the classes in the java.util.correct package.
You mean java.util.concurrent, right?
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Eh... That's correct
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
| Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |











