?? guithread.java
字號:
import java.awt.*;
import java.awt.event.*;
public class GuiThread
{
public static void main(String args[]) throws Exception
{
Frame f=new Frame();
Button b=new Button("Press me");
myListener m=new myListener();
b.addActionListener(m);
f.add(b,"Center");
f.setSize(100,60);
f.setVisible(true);
f.addWindowListener(m);
myThread.view();
}
}
class myListener extends WindowAdapter implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
myThread.view();
}
public void windowClosing(WindowEvent we)
{
myThread.view();
System.exit(0);
}
}
class myThread{
public static void view()
{
Thread t=Thread.currentThread();
System.out.println("當前線程:"+t.getName());
int n=Thread.activeCount();
System.out.println("活動線程個數:"+n);
Thread threads[]=new Thread[n];
t.enumerate(threads);// 枚舉數組
for(Thread thread:threads)
{
String s=thread.isDaemon()?"后臺線程":"前臺線程";
System.out.println(s+":"+thread.getName());
}
System.out.println("---------------------");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -