⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groupdemo.java

📁 Java网络编程与分布式计算, 主要分析java网络各方面的编程, 提供许多实用安全
💻 JAVA
字号:
// Chapter 7, Listing 10
public class GroupDemo implements Runnable
{
	public static void main(String args[]) throws Exception
	{
		// Create a thread group
		ThreadGroup parent = new ThreadGroup("parent");

		// Create a group that is a child of another thread group
		ThreadGroup subgroup = new ThreadGroup(parent, "subgroup");

		// Create some threads in the parent, and subgroup class
		Thread t1 = new Thread ( parent, new GroupDemo() );
		t1.start();
		Thread t2 = new Thread ( parent, new GroupDemo() );
		t2.start();
		Thread t3 = new Thread ( subgroup, new GroupDemo() );
		t3.start();

		// Dump the contents of the group to System.out
		parent.list();


		// Wait for user, then terminate
		System.out.println ("Press enter to continue");
		System.in.read();
		System.exit(0);
	}

	public void run()
	{
		// Do nothing
		for(;;)
		{
			Thread.yield();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -