Skip to content

Commit 502df42

Browse files
committed
update
1 parent b01f882 commit 502df42

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

02nio/nio01/src/main/java/java0/nio01/netty/NettyHttpServer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public static void main(String[] args) throws InterruptedException {
2222
try {
2323
ServerBootstrap b = new ServerBootstrap();
2424
b.option(ChannelOption.SO_BACKLOG, 128)
25-
.option(ChannelOption.TCP_NODELAY, true)
26-
.option(ChannelOption.SO_KEEPALIVE, true)
27-
.option(ChannelOption.SO_REUSEADDR, true)
28-
.option(ChannelOption.SO_RCVBUF, 32 * 1024)
29-
.option(ChannelOption.SO_SNDBUF, 32 * 1024)
30-
.option(EpollChannelOption.SO_REUSEPORT, true)
25+
.childOption(ChannelOption.TCP_NODELAY, true)
3126
.childOption(ChannelOption.SO_KEEPALIVE, true)
32-
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
27+
.childOption(ChannelOption.SO_REUSEADDR, true)
28+
.childOption(ChannelOption.SO_RCVBUF, 32 * 1024)
29+
.childOption(ChannelOption.SO_SNDBUF, 32 * 1024)
30+
.childOption(EpollChannelOption.SO_REUSEPORT, true)
31+
.childOption(ChannelOption.SO_KEEPALIVE, true)
32+
.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
3333

3434
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
3535
.handler(new LoggingHandler(LogLevel.INFO))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package java0.conc0301;
2+
3+
public class ThreadCount {
4+
public static void main(String[] args) throws InterruptedException {
5+
//System.out.println("system:"+Thread.currentThread().getThreadGroup().getParent());
6+
Thread.currentThread().getThreadGroup().getParent().list();
7+
8+
// System.out.println("main:"+Thread.currentThread().getThreadGroup());
9+
// Thread.currentThread().getThreadGroup().list();
10+
}
11+
}

03concurrency/0301/src/main/java/java0/conc0301/op/Join.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ public static void main(String[] args) {
66
Object oo = new Object();
77

88
MyThread thread1 = new MyThread("thread1 -- ");
9-
thread1.setOo(thread1);
9+
//oo = thread1;
10+
thread1.setOo(oo);
1011
thread1.start();
1112

12-
synchronized (thread1) { // 这里用oo或thread1/this
13+
synchronized (oo) { // 这里用oo或thread1/this
1314
for (int i = 0; i < 100; i++) {
1415
if (i == 20) {
1516
try {
16-
thread1.join();
17+
oo.wait(0);
18+
//thread1.join();
1719
} catch (InterruptedException e) {
1820
e.printStackTrace();
1921
}
@@ -40,7 +42,7 @@ public MyThread(String name) {
4042

4143
@Override
4244
public void run() {
43-
synchronized (this) { // 这里用oo或this,效果不同
45+
synchronized (oo) { // 这里用oo或this,效果不同
4446
for (int i = 0; i < 100; i++) {
4547
System.out.println(name + i);
4648
}

0 commit comments

Comments
 (0)