Skip to content

Commit

Permalink
auto commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CyC2018 committed Jan 8, 2020
1 parent 5f005e2 commit f84b140
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions docs/notes/Java 并发.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,23 @@
- 实现 Callable 接口
- 继承 Thread

实现 Runnable Callable 接口的类只能当做一个可以在线程中运行的任务不是真正意义上的线程因此最后还需要通过 Thread 来调用可以说任务是通过线程驱动从而执行的
实现 Runnable Callable 接口的类只能当做一个可以在线程中运行的任务不是真正意义上的线程因此最后还需要通过 Thread 来调用可以理解为任务是通过线程驱动从而执行的

## 实现 Runnable 接口

需要实现 run() 方法

通过 Thread 调用 start() 方法来启动线程
需要实现接口中的 run() 方法

```java
public class MyRunnable implements Runnable {
@Override
public void run() {
// ...
}
}
```

使用 Runnable 实例再创建一个 Thread 实例然后调用 Thread 实例的 start() 方法来启动线程

```java
public static void main(String[] args) {
MyRunnable instance = new MyRunnable();
Expand Down
2 changes: 1 addition & 1 deletion docs/notes/Socket.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ else
select poll 的功能基本相同不过在一些实现细节上有所不同

- select 会修改描述符 poll 不会
- select 的描述符类型使用数组实现FD_SETSIZE 大小默认为 1024因此默认只能监听 1024 个描述符如果要监听更多描述符的话需要修改 FD_SETSIZE 之后重新编译 poll 没有描述符数量的限制
- select 的描述符类型使用数组实现FD_SETSIZE 大小默认为 1024因此默认只能监听少于 1024 个描述符如果要监听更多描述符的话需要修改 FD_SETSIZE 之后重新编译 poll 没有描述符数量的限制
- poll 提供了更多的事件类型并且对描述符的重复利用上比 select
- 如果一个线程对某个描述符调用了 select 或者 poll另一个线程关闭了该描述符会导致调用结果不确定

Expand Down
9 changes: 5 additions & 4 deletions notes/Java 并发.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,23 @@
- 实现 Callable 接口
- 继承 Thread

实现 Runnable Callable 接口的类只能当做一个可以在线程中运行的任务不是真正意义上的线程因此最后还需要通过 Thread 来调用可以说任务是通过线程驱动从而执行的
实现 Runnable Callable 接口的类只能当做一个可以在线程中运行的任务不是真正意义上的线程因此最后还需要通过 Thread 来调用可以理解为任务是通过线程驱动从而执行的

## 实现 Runnable 接口

需要实现 run() 方法

通过 Thread 调用 start() 方法来启动线程
需要实现接口中的 run() 方法

```java
public class MyRunnable implements Runnable {
@Override
public void run() {
// ...
}
}
```

使用 Runnable 实例再创建一个 Thread 实例然后调用 Thread 实例的 start() 方法来启动线程

```java
public static void main(String[] args) {
MyRunnable instance = new MyRunnable();
Expand Down
2 changes: 1 addition & 1 deletion notes/Socket.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ else
select poll 的功能基本相同不过在一些实现细节上有所不同

- select 会修改描述符 poll 不会
- select 的描述符类型使用数组实现FD_SETSIZE 大小默认为 1024因此默认只能监听 1024 个描述符如果要监听更多描述符的话需要修改 FD_SETSIZE 之后重新编译 poll 没有描述符数量的限制
- select 的描述符类型使用数组实现FD_SETSIZE 大小默认为 1024因此默认只能监听少于 1024 个描述符如果要监听更多描述符的话需要修改 FD_SETSIZE 之后重新编译 poll 没有描述符数量的限制
- poll 提供了更多的事件类型并且对描述符的重复利用上比 select
- 如果一个线程对某个描述符调用了 select 或者 poll另一个线程关闭了该描述符会导致调用结果不确定

Expand Down

0 comments on commit f84b140

Please sign in to comment.