thread volatile SwingUtilities.invokeLater()
salut,
j'ai deux problèmes :
-dans quel cas doit on déclarer un thread volatile (c'est quoi un thread volatile)?
-je ne comprend ce que fait la methode doUpdate:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| try{
String msg;
while(Thread.currentThread()==t && (msg=sockin.readLine())!=null){
final String output=msg;
doUpdate(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
anzeige.append(output+"\n");
}
});
} |
Code:
1 2 3
| private void doUpdate(Runnable r){
SwingUtilities.invokeLater(r);
} |
en fait" t" est un thread volatile et "anzeige" est un JTextArea
et tout ce code se trouve dans une méthode run().