Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Date; public class Main { /** * Print a string on console with date and invoking thread name. * This method is not buffered, and will be flushed on encountering new-line. * @param string string to be printed */ public static void print(String string) { System.out.print("[" + new Date(System.currentTimeMillis()) + "] " + Thread.currentThread().getName() + ": " + string); } /** * Util method: getName of executing thread * @return invoking thread name */ public static String getName() { return Thread.currentThread().getName(); } }