美文网首页
advance programming期末复习

advance programming期末复习

作者: Jessieee_Y | 来源:发表于2018-01-15 20:01 被阅读0次

主要是课件上需要记忆的,还有空手写代码时的小细节。考前串一下。

week1 thread

thread 的概念:Thread is a lightweight process which has its own cache, can run and share data with other threads.

2 ways to creat thread.

1).Extend thread. e.g.Thread t=new thread(); trigger default contributor with no argument to run.

2).implement Runnable interface, and creat new thread.

start()和run()的区别:

When start() is invoked, the thread goes into ready status, which means it is eligble for running. Excution of the thread starts when run() method is called by JVM.

3 way terminate thread: 不写了 课件上有

Synchronized 和volatile的区别:

only primitive variable can be declared as volatile; volatile cannot protect complex codes; Access to volatile variable cannot has the potential to be protected.

Entry set&Wait set

When a thread wants to access to a block of code protected by synchronized, but it doesn't have the lock, it is in entry set.

When it get the lock, but other threads are excuting that code, the thread needs to enter wait set by callng the wait() method. And this thread will stay in wait() until notify().

lock&read write lock:

lock means only one thread can be permitted to excute this block of code, but sometime it is slow. Read write lock permits more readers at the same time and only one writer.

Synchronized 3种作用范围:

1.synchronized method 2.括号里加some objects 3. an object can use itself as a lock e.g.synchronized(this)

week 1 socket

概念:creat connection to remote computers to receive and send data.

空手写代码:server端和client端

【注】都要import java.net.*; import java.io.*;

都要bufferedReader in=new BufferedReader(new InputStreamReader(socket.getInputStream()));

PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(),true)));       //可以说是巨难背了

server端:有一个变量 public static final int PORT=8080;

有两个try

client端:InetAddress addr=InetAddress.getByName(127.0.0.1);

如果要multiple clients 就写个while loop 里 s.accept();

week 2

Serializable

import java.io.*; serializable is marker interface, no method to implement.

OutputStream outputFile=new FileOutputStream("....ser");

ObjectOutputStream cout=new ObjectOutputStream(outputFile);

outputFile.writeObject(object);

最后加两个close().

RMI

概念:send java objects and invoke methods form remote computer.

主要4部分: interface,impl, server, client

interface: import java.rmi.remote; 因为它要extends Remote.

impl: import java.rmi.*; import java.rmi.server.*; 然后extends UnicastRemoteObject implement interface.

server和client都import java.rmi.naming;

Stub和Skeleton的作用

Stub 3点

1)Implement same interface as server; 2)serialize argument to call the remote method and send to server; 3)receive and deserialize the result

Skeleton 4点

1)Receive the remote call of method 2)deserialize the parameters; 3)find a suitable method on behalf of remote client 4)serilaize and send back the result to client

RMI registry: a program that keeps mapping of remote object interfaces.

HTTP

HTTP request response header会画

TCP 结构图

...


week 3,week 4还没整理完就考试了, 就酱吧~

相关文章

  • advance programming期末复习

    主要是课件上需要记忆的,还有空手写代码时的小细节。考前串一下。 week1 thread thread 的概念:T...

  • Advance Java Programming.pdf 免费

    下载地址:Advance Java Programming[www.rejoiceblog.com].pdf

  • 期末复习

    软件构造的多维度视图 多维2 静态类型检查 Mutable/Immutable 第三章屁屁踢 前置/后置条件 AD...

  • 期末复习

    天气越来越热,工作也越来越忙了。为了能更好提升教学质量,我努力在复习教学方面能有更多的创意,希望能让学生现在一定的...

  • 期末复习

    2018年6月23日雨天 一大早起来,就乘坐8路公交车奔往学校。 大约在七点左右到校,但早已到校的同学有四五个了,...

  • 期末复习

    一、对课文内容的复习。 引导学生读课文,回顾课文内容,要求要背诵的课文,大家齐背。师生进行口头填空,巩固课文内容。...

  • 《期末复习》

    叽叽喳喳,叽叽喳喳 在安静的夜里,烦躁一直在吵在闹 它恶毒的行为不放过我的每个细胞 吵得脑壳疼,闹得心脏累 让我觉...

  • 期末复习

    话题299 家长如何指导孩子做好期末复习迎考工作 《唐山家庭教育论坛群》QQ:218625335 由群友提议 主持...

  • 期末复习

    期末复习的状态大抵是 预习了很多 还有很多 花了一天半终于全部看了一遍 可是我要做的是背下来啊 今天在图书馆待了一...

  • 期末复习

    看书 这学期的光学,在学的时候抄了笔记,但只是抄了而已,什么都不记得,只觉得知识点乱七八糟的……最后复习的时候,用...

网友评论

      本文标题:advance programming期末复习

      本文链接:https://www.haomeiwen.com/subject/flrloxtx.html