简单Web服务器设计与实现课程设计(8)

2021-01-20 18:12

计算机网络课设报告,java平台实现,Java;HTTP;Web服务器

阻塞解除条件为其它线程调用该资源的notify()或notifyAll()。

下面一个例子实践了如何通过上述两种方法创建线程并启动它们:

// 通过Thread类的子类创建的线程;

class thread1 extends Thread

{ file://自定义线程的run()方法;

public void run()

{

System.out.println("Thread1 is running…");

}

}

file://通过Runnable接口创建的另外一个线程;

class thread2 implements Runnable

{ file://自定义线程的run()方法;

public void run()

{

System.out.println("Thread2 is running…");

}

}

file://程序的主类'

class Multi_Thread file://声明主类;

{

plubic static void mail(String args[]) file://声明主方法;

{

thread1 threadone=new thread1(); file://用Thread类的子类创建线程; Thread threadtwo=new Thread(new thread2()); file://用Runnable接口类的对象创建线程;

threadone.start(); threadtwo.start(); file://strat()方法启动线程;

}

}

运行该程序就可以看出,线程threadone和threadtwo交替占用CPU,处于并行运行


简单Web服务器设计与实现课程设计(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2013年中国十大证券公司排行榜

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: