20165225 Java programming Eighth week of study summary

Source: Internet
Author: User

Tag: res daemon effect notification interrupt set Ali IsAlive get

20165225 "Java Programming" Eighth Week study summary 1. Video and textbook Learning:
    • 12th Chapter Study Summary
1.继承Thread类创建线程,程序中如果想要获取当前线程对象可以使用方法:Thread.currentThread();如果想要返回线程的名称,则可以使用方法:getName();2.实现Runnable接口创建线程3.使用Callable和Future创建线程线程常用方法:start()run()定义线程线程对象被调度之后所执行的操作sleep(int millsecond),必须在try-catch语句块中调用sleep方法isAlive()协调同步的常用方法:wait()方法可以中断方法的执行,使本线程等待,暂时让出CPU的使用权,并允许其它线程使用这个同步方法notifyAll()方法通知所有的由于使用这个同步方法而处于等待的线程结束等待。曾中断的线程就会从刚才的中断处继续执行这个同步方法,并遵循“先中断先继续”的原则notify()方法只是通知处于等待中的线程的某一个结束等待线程联合:一个线程A在占有CPU资源期间,可以让其它线程调用join()和本线程联合AWT-EventQuecue线程负责处理GUI事件,AWT-Windows线程负责将窗体或组件绘制到桌面B.join()若准备联合的B线程已经执行结束,则B.join()不会产生任何效果使用Timer类的方法start()启动计时器,即启动线程。使用Timer类的方法stop()停止计时器,即挂起线程,使用restart()重新启动计时器,即恢复线程守护线程:一个线程调用void setDaemon(boolean on)方法可以将自己设置成一个守护(Daemon)线程thread.setDaemon(true);当程序中的所有用户线程都已结束运行时,即使守护线程的run方法中还有需要执行的语句,守护线程也立刻结束运行
2. Code hosting:

3. Last week's summary of the wrong title:
周一啦
4. Learning Experience:
    • When the thread died, I was dead, too.

    • Have a nice weekend.

    • Please buy No. tears left to Cry on itunes!? (′▽ ')

20165225 Java programming Eighth week of study summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.