Results 1 to 3 of 3
Thread: Thread Problem
- 02-04-2011, 12:34 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Thread Problem
Here is the code that i am currently working. The problem is when i start the thread and then the showmessage appears. THe next message wont appear. The thread stops whenever the message appear. is there a way that the message will stack up without closing the first message first?
public Thread stream = new Thread(){
// This method is called when the thread runs
@Override
public void run() {
while (true) {
JOptionPane.showMessageDialog(null, "Number: "+ ctr);
ctr++;
try {
stream.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Main_Menu.class.getName()).log(Le vel.SEVERE, null, ex);
}
}
}
};// end thread
- 02-04-2011, 05:31 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
JOptionPane is modal. What that means is that it locks up the AWT thread until the user makes a selection ("ok", "cancel", etc.). If you want an joptionpane equivalent that does not block the AWT thread, you have to write one yourself and you have to be very careful, because swing is not thread safe.
- 02-07-2011, 12:12 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Thread location problem?
By AMaineJR in forum Threads and SynchronizationReplies: 1Last Post: 10-01-2010, 03:38 AM -
Thread problem.
By Mekonom in forum New To JavaReplies: 4Last Post: 03-16-2010, 04:19 PM -
thread problem
By Harris68 in forum NetworkingReplies: 3Last Post: 03-03-2010, 07:53 PM -
Problem with a thread
By dotabyss in forum Threads and SynchronizationReplies: 3Last Post: 02-14-2010, 10:56 PM -
Problem using thread +rmi in my homework
By IbrahimAbbas in forum Threads and SynchronizationReplies: 10Last Post: 04-14-2008, 09:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks