atitit.产品console 日志的aticonsole 方案处理总结

atitit.产品console 日志的aticonsole 方案处理总结

1. 主要原理流程 1

2. 调用代码 1

3. 内部主要实现 1

3.1. 放入消息 1

3.2. 读取消息 2

默认可以console做日志。。

但是有些需要多行文本框做log

1. 主要原理流程

LinkedBlockingQueue  把消息放入。。

一个ui线程读取消息。。使用阻塞模式。。

 

2. 调用代码

prjatimail  /AtiSkinSwing

axnew AccTester(threadCount);

ax.msgboxC=new ConsoleBox(textArea);

 

注入msgbox来实现放入消息,,构造textarea来实现写出消息。。

 

 

作者:: 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://blog.csdn.net/attilax

 

 

3. 内部主要实现

3.1. 放入消息

msgboxC.put(em + "," + pwd + " 成功\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. 读取消息

  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 获取信息timer stop");

 break;

 }

 try {

 //final int n = i;

 core.sleep(300);

 String v = null;

 try {

 v = rztQueue.take();

 catch (InterruptedException e) {

 e.printStackTrace();

 }

 jTextArea1.append("\r\n" + v + " !");

 //jTextArea1.paintImmediately(jTextArea1.getBounds());

 jTextArea1.setCaretPosition(jTextArea1.getText()

 .length());// 滚动到底端

 catch (Exception e) {

 e.printStackTrace();

 }

 }

 }

 });

}

原文地址:https://www.cnblogs.com/attilax/p/15198950.html