Atitit. Product Console of the log Aticonsole Program Processing Summary
1. Main principle Flow 1
2. Calling code 1
3. Internal main Realization 1
3.1. Put message 1
3.2. Reading messages 2
The console can log by default .
But some need a multiline text box to do log
1. Main principle Flow
Linkedblockingqueue put the message into a.
A UI thread reads the message: Use blocking mode:
2. Calling code
PRJ. atimail/atiskinswing
Ax = New acctester (threadcount);
Ax . Msgboxc = New Consolebox (textArea);
injected MsgBox to implement the put message, construct the textarea to implement the write message.
Author:: Old Wow's paw attilax Ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
3. Internal main realization 3.1. Put messages
Msgboxc . Put (em + "," + pwd + "success \ r \ n");
Public linkedblockingqueue<string> Rztqueue = New linkedblockingqueue<string> ();
Public void put(string string) {
Try {
Rztqueue . Put (string);
} catch (interruptedexception e) {
// TODO auto-generated Catch block
e . Printstacktrace ();
}
}
3.2. Reading messages
private void ini () {
//msg Collect process
es_single. Execute (new Runnable () {
@Override
public void Run () {
while (true) {
//msgstopflag=true;
if(msgstopflag)
{
jTextArea1. Append ("\ r \ n Get information timer stop");
break;
}
Try {
//final int n = i;
core. Sleep (a);
String v = null;
Try {
v = rztqueue. Take ();
} catch (interruptedexception e) {
e. Printstacktrace ();
}
jTextArea1. Append ("\ r \ n" + v + "!) ");
//jtextarea1.paintimmediately (Jtextarea1.getbounds ());
jTextArea1setcaretposition (jTextArea1. GetText ()
. Length ()); //Scroll to the end
} catch (Exception e) {
e. Printstacktrace ();
}
}
}
});
}
Atitit. Summary of Aticonsole Scheme processing for product console log