java.util.logging.Logger中的log方法的执行行顺序?

suncheng_hong 2007-06-15 02:39:07
package step1;

import java.util.logging.Level;
import java.util.logging.Logger;


public class HelloSpeaker {
private Logger logger = Logger.getLogger(this.getClass().getName());
public void hello(String name){

logger.log(Level.INFO,"hello method starts....");
System.out.println("Hello, " + name);
logger.log(Level.INFO,"hello method ends....");

}
}
执行结果:
Hello, abc
2007-6-15 14:38:00 step1.HelloSpeaker hello
信息: hello method starts....
2007-6-15 14:38:00 step1.HelloSpeaker hello
信息: hello method ends....

为什么不是:


2007-6-15 14:38:00 step1.HelloSpeaker hello
信息: hello method starts....
Hello, abc
2007-6-15 14:38:00 step1.HelloSpeaker hello
信息: hello method ends....

...全文
301 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
suncheng_hong 2007-06-15
  • 打赏
  • 举报
回复
果然有效额.
是我cpu太强了.程序都分辨不了啦。呵呵。。
AllanJD 2007-06-15
  • 打赏
  • 举报
回复
^_^,你被忽悠了!

44这个!
package com.ajd.csdn;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Logging {

/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
Logger logger = Logger.getLogger(new Logging().getClass().getName());

logger.log(Level.INFO, "Start...");
Thread.sleep(1000);
System.out.println("Between start and end.");
logger.log(Level.INFO, "End...");
}

}

其实是系统打印的问题啊,太快了,呵呵!

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧