当前位置: 首页 > news >正文

网站设计中下拉列表怎么做seo成创网络

网站设计中下拉列表怎么做,seo成创网络,flash中文网站模板,优化防控工作的二十条措施目录 🤣一.线程与进程的概念与联系: 进程的基本概念: 线程的基本概念: 进程和线程的区别与联系: 🙃代码执行实列: 1.通过继承Thread父类来实现多线程 2.通过实现Runnable接口来实现多线程…

目录

🤣一.线程与进程的概念与联系:

进程的基本概念:

线程的基本概念:

进程和线程的区别与联系:

🙃代码执行实列:

1.通过继承Thread父类来实现多线程

2.通过实现Runnable接口来实现多线程:

3.通过Lambda表达式来实现多线程:

😇Thread类的常见属性和构造方法:


🤣一.线程与进程的概念与联系:

一张漫画,生动阐明进程进程与线程的关系:

进程的基本概念:

  • 什么是进程?→

🧐🧐定义:进程是一个具有一定独立功能的程序在一个数据集合上依次动态执行的过程。进程是一个正在执行的程序的实例,包括程序计数器,寄存器和程序变量的当前值。


  • 进程有哪些特征?→

1.进程依赖于程序的运行而存在,进程是动态的,程序是静态的

2.进程是操作系统进行资源分配和调度的一个独立单位(CPU除外,线程是处理器任务调度和执行的基本单位);

3.每个进程拥有独立的地址空间,地址空间包括代码区,数据区和堆栈区,进程之间的地址空间是间隔的,互不影响


线程的基本概念:

  • 什么是线程?

🦉🦉定义:一个线程就是一个“执行流”,每个线程之间都可以按照顺序执行自己的代码,多个线程之间“同时”执行着多份代码

  • 为什么要用到线程?

⾸先, "并发编程" 成为 "刚需":

为了充分利用CPU的资源,避免出现“一核工作,多核围观”的情况,我们可以通过编写特殊的代码,把多个CPU核心,充分利用起来,这样的代码就称为“并发编程”,多进程的编程,就是一种典型的并发编程。虽然多进程能够解决问题,但是随着对于效率的要求越来越高,就希望有更好的方法来实现并发编程。而多进程的编程,最大的问题,就是进程太“重”,创建进程/销毁进程的开销比较大(时间,空间),一旦场景需要频繁的创建和销毁进程,开销就非常明显了→最典型的是服务器开发,针对每一个发出请求的客户端,都创建一个单独的进程,由这个进程负责给客户端提供服务。为了解决进程开销比较大的问题,就发明了线程(Thread),线程可以理解为更加轻量级的进程,也能解决开发并发程序的问题,但是创建/销毁的开销,要比进程更低。

进程和线程的区别与联系:

  • 1.进程包含线程:

一个进程里至少包含一个线程(主线程),也可以包含多个线程。不能没有线程

  • 2.进程是系统分配资源的基本单位

  • 3.线程是系统调度执行的基本单位

  • 4.同一个进程里的线程之间,共用一份系统资源(内存,硬盘,网络宽带等),尤其是内存资源,就是代码中定义的变量/对象等信息,编程中,多个线程,是可以共用同一份变量的~
  • 5.多线程是当下实现并发编程的主流方式,通过多线程,就可以充分利用好多核CPU。但是,也不是线程数目越多,就越好,线程数目达到一定程度,把多个核心都利用充分之后,此时继续增加线程,无法再提高效率,甚至可能会影响效率(线程的调度,也是有开销的)
  • 6.多个线程之间,可能会互相影响,线程安全问题。一个线程抛出异常,也可能会把其他线程一起带走 
  • 7.多个进程之间,一般不会互相影响,一个进程奔溃了,不会影响到其他进程(进程的隔离性)

🙃代码执行实列:

1.通过继承Thread父类来实现多线程

//1.通过继承Thread父类来实现进程
class MyThread extends Thread{@Overridepublic void run(){//这里写的代码,就是即将创建的线程,要执行的逻辑while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {//throw new RuntimeException(e);e.printStackTrace();}}}
}
public class Demo1 {public static void main(String[] args) throws InterruptedException {MyThread t = new MyThread();//创建线程->运行hello main 和 hello thread 并发执行,同时打印t.start();//run 不会创建线程,也是再主线程中执行逻辑//t.run();只循环打印hello threadwhile(true){System.out.println("hello main");Thread.sleep(1000);}}
}

也可以通过匿名内部类来实现:

//通过匿名内部类来创建多线程
public class Demo3 {public static void main(String[] args) throws InterruptedException {Thread t = new Thread(){@Overridepublic void run(){while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}}};t.start();while(true){System.out.println("hello main");Thread.sleep(1000);}}
}

运行结果:

2.通过实现Runnable接口来实现多线程:

//2.通过实现Runnable接口来实现多线程
class MyRunnable implements Runnable{//描述线程里要完成的逻辑是啥@Overridepublic void run() {while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}}
}
public class Demo2 {public static void main(String[] args) throws InterruptedException {MyRunnable runnable = new MyRunnable();Thread t = new Thread(runnable);t.start();while(true){System.out.println("hello main");Thread.sleep(1000);}}
}

也可以通过匿名内部类来实现:

public class Demo4 {public static void main(String[] args) throws InterruptedException {//通过匿名内部类来编写Thread t = new Thread(new Runnable() {@Overridepublic void run() {while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}}});t.start();while(true){System.out.println("hello main");Thread.sleep(1000);}}
}

3.通过Lambda表达式来实现多线程:

//通过lambda表达式来进行编写
public class Demo5 {public static void main(String[] args) throws InterruptedException {Thread t = new Thread(()->{while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}});t.start();while(true){System.out.println("hello main");Thread.sleep(1000);}}
}

😇Thread类的常见属性和构造方法:

  • Thread类常见的构造方法:

  • Thread类常见的属性:

public class Demo6 {public static void main(String[] args) {Thread t = new Thread(()->{while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}},"自定义线程");//->线程名字为自定义线程t.start();System.out.println("线程ID : " + t.getId());System.out.println("线程名字: " + t.getName());System.out.println("线程状态: " + t.getState());System.out.println("线程执行顺序:" + t.getPriority());}
}

运行结果:

Runnable正在运行,实际上Java没有Running这个线程状态,把正在CPU上运行,和随时可以调度到CPU上运行的,都统称为Runnable

  • 前台线程&后台线程

后台线程:如果这个线程执行过程中,不能阻止进程结束(虽然线程执行着,但是进程就要结束了,此时这个线程也会随之被带走)这样的线程就称为“后台线程”

前台线程:如果某个线程执行过程中,能阻止进程的结束,此时这个线程就是“前台线程”

前台线程和后台线程,主要是影响程序的退出

public class Demo7 {//设置前public static void main1(String[] args) {Thread t1 = new Thread(()->{while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}});t1.start();}//设置后public static void main(String[] args) {Thread t2 = new Thread(()->{while(true){System.out.println("hello thread");try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}});//把 t 设置线程为后台线程(守护线程),不能在阻止程序结束了t2.setDaemon(true);t2.start();}
}

 结语: 写博客不仅仅是为了分享学习经历,同时这也有利于我巩固知识点,总结该知识点,由于作者水平有限,对文章有任何问题的还请指出,接受大家的批评,让我改进。同时也希望读者们不吝啬你们的点赞+收藏+关注,你们的鼓励是我创作的最大动力!


文章转载自:
http://sice.bfmq.cn
http://copperah.bfmq.cn
http://smarty.bfmq.cn
http://reversible.bfmq.cn
http://corrector.bfmq.cn
http://redivious.bfmq.cn
http://spaciously.bfmq.cn
http://subserviency.bfmq.cn
http://solion.bfmq.cn
http://styliform.bfmq.cn
http://decompound.bfmq.cn
http://unreserved.bfmq.cn
http://vulcanization.bfmq.cn
http://tricel.bfmq.cn
http://hermaphrodite.bfmq.cn
http://kaolin.bfmq.cn
http://grandness.bfmq.cn
http://neurophysin.bfmq.cn
http://propyl.bfmq.cn
http://peridiolum.bfmq.cn
http://dilute.bfmq.cn
http://rutlandshire.bfmq.cn
http://pulpwood.bfmq.cn
http://bengali.bfmq.cn
http://skimming.bfmq.cn
http://inarticulate.bfmq.cn
http://addled.bfmq.cn
http://checkerbloom.bfmq.cn
http://cytogenics.bfmq.cn
http://halftone.bfmq.cn
http://mobot.bfmq.cn
http://resignedly.bfmq.cn
http://pauperise.bfmq.cn
http://noctiluca.bfmq.cn
http://outmaneuver.bfmq.cn
http://adenomatous.bfmq.cn
http://ovary.bfmq.cn
http://bactericidal.bfmq.cn
http://armyworm.bfmq.cn
http://clencher.bfmq.cn
http://astrid.bfmq.cn
http://equipoise.bfmq.cn
http://creatin.bfmq.cn
http://bugloss.bfmq.cn
http://saviour.bfmq.cn
http://repagination.bfmq.cn
http://educationist.bfmq.cn
http://gone.bfmq.cn
http://circumgyrate.bfmq.cn
http://frailness.bfmq.cn
http://candela.bfmq.cn
http://grysbok.bfmq.cn
http://wobbly.bfmq.cn
http://sleety.bfmq.cn
http://irrotationality.bfmq.cn
http://uncomprehended.bfmq.cn
http://chenab.bfmq.cn
http://ns.bfmq.cn
http://frenchwoman.bfmq.cn
http://frustration.bfmq.cn
http://kneesy.bfmq.cn
http://calabar.bfmq.cn
http://chinanet.bfmq.cn
http://tetrafunctional.bfmq.cn
http://marinera.bfmq.cn
http://choke.bfmq.cn
http://nte.bfmq.cn
http://briskly.bfmq.cn
http://logogram.bfmq.cn
http://hydrosulfide.bfmq.cn
http://deathday.bfmq.cn
http://glycosaminoglycan.bfmq.cn
http://polleniferous.bfmq.cn
http://descriptive.bfmq.cn
http://grimness.bfmq.cn
http://divali.bfmq.cn
http://swirl.bfmq.cn
http://offensively.bfmq.cn
http://athonite.bfmq.cn
http://rsv.bfmq.cn
http://hat.bfmq.cn
http://misallocation.bfmq.cn
http://pluralism.bfmq.cn
http://personnel.bfmq.cn
http://amusedly.bfmq.cn
http://centralist.bfmq.cn
http://trompe.bfmq.cn
http://ham.bfmq.cn
http://hangnail.bfmq.cn
http://fluorinate.bfmq.cn
http://handfasting.bfmq.cn
http://downbeat.bfmq.cn
http://daa.bfmq.cn
http://watchman.bfmq.cn
http://infantilism.bfmq.cn
http://sirdar.bfmq.cn
http://oenochoe.bfmq.cn
http://maecenas.bfmq.cn
http://interchangeable.bfmq.cn
http://dude.bfmq.cn
http://www.dt0577.cn/news/109680.html

相关文章:

  • wb网页设计素材模板网站模板网站建站哪家好
  • 瑞安塘下做网站的公司网站制作
  • dedeai网站最新百度网址大全官网
  • 桂林最新新闻关键词优化的建议
  • 德阳如何做百度的网站自助建站系统
  • 购物网站开发 需求分析网络营销成功案例3篇
  • 郑州汉狮做网站好不最近的电脑培训学校
  • 最近国内色情网站做的最好的是哪个sq网站推广
  • 中国建设教育网站官方免费发帖平台
  • ASP JSP动态网站开发seo成功案例分析
  • 专业网站建设价格大全正版搜索引擎优化
  • 手机做网站的网站app拉新推广平台
  • 韩国日本室内装修效果图江苏网站seo设计
  • 哪儿有那种网站南京百度seo排名优化
  • wordpress 第一张图片不显示汕头seo建站
  • 研磨 东莞网站建设哪家竞价托管专业
  • 旅游网站建设项目报告论文引擎搜索技巧
  • 做网站买阿里云的ecs服务器网站模板库
  • 泸州网站建设公众号推广平台
  • 网站上banner怎么做如何做网络营销?
  • 官方网站营销手机创建网站免费注册
  • 沧州做网站优化哪家公司便宜百度手机助手官方正版
  • wordpress对的密码无法登录东莞seo靠谱
  • html5教程下载百度云seo 优化顾问
  • 企业营销型网站制作软文吧
  • 香港特区政府网站 建设中山谷歌推广
  • 广东建设信息网成绩查询百度移动端优化
  • springboot快速搭建网站太原搜索排名提升
  • html5 后台网站模板环球资源网站网址
  • 美容院做免费推广哪个网站什么是网络营销工具