Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
武汉红喜
whatsmars
提交
683f2827
W
whatsmars
项目概览
武汉红喜
/
whatsmars
通知
3
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
683f2827
编写于
8月 11, 2019
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
java
上级
3b7bd399
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
59 addition
and
39 deletion
+59
-39
whatsmars-common/src/main/java/org/hongxi/whatsmars/common/Constants.java
.../src/main/java/org/hongxi/whatsmars/common/Constants.java
+1
-3
whatsmars-common/src/test/java/org/hongxi/java/net/TCPClient.java
...s-common/src/test/java/org/hongxi/java/net/TCPClient.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/net/TCPServer.java
...s-common/src/test/java/org/hongxi/java/net/TCPServer.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/net/UDPClient.java
...s-common/src/test/java/org/hongxi/java/net/UDPClient.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/net/UDPServer.java
...s-common/src/test/java/org/hongxi/java/net/UDPServer.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/nio/MappedFileTest.java
...mon/src/test/java/org/hongxi/java/nio/MappedFileTest.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/nio/MultiPortEcho.java
...mmon/src/test/java/org/hongxi/java/nio/MultiPortEcho.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/util/Java8Test.java
...-common/src/test/java/org/hongxi/java/util/Java8Test.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CallableTest.java
...st/java/org/hongxi/java/util/concurrent/CallableTest.java
+2
-3
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CompletionServiceTest.java
...rg/hongxi/java/util/concurrent/CompletionServiceTest.java
+4
-0
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CountDownLatchTest.java
...a/org/hongxi/java/util/concurrent/CountDownLatchTest.java
+1
-3
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CyclicBarrierTest.java
...va/org/hongxi/java/util/concurrent/CyclicBarrierTest.java
+14
-10
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/ExchangerTest.java
...t/java/org/hongxi/java/util/concurrent/ExchangerTest.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/FutureTaskTest.java
.../java/org/hongxi/java/util/concurrent/FutureTaskTest.java
+2
-3
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/InterruptTest.java
...t/java/org/hongxi/java/util/concurrent/InterruptTest.java
+1
-3
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/InterruptedTest.java
...java/org/hongxi/java/util/concurrent/InterruptedTest.java
+4
-5
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/InvokeAllTest.java
...t/java/org/hongxi/java/util/concurrent/InvokeAllTest.java
+1
-3
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/ReentrantLockTest.java
...va/org/hongxi/java/util/concurrent/ReentrantLockTest.java
+3
-0
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/RunnableTest.java
...st/java/org/hongxi/java/util/concurrent/RunnableTest.java
+1
-3
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/ScheduleTest.java
...st/java/org/hongxi/java/util/concurrent/ScheduleTest.java
+1
-3
未找到文件。
whatsmars-common/src/main/java/org/hongxi/whatsmars/common/Constants.java
浏览文件 @
683f2827
...
@@ -3,9 +3,7 @@ package org.hongxi.whatsmars.common;
...
@@ -3,9 +3,7 @@ package org.hongxi.whatsmars.common;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
/**
/**
* Created on 2019/8/5.
* @author shenhongxi 2019/8/5
*
* @author shenhongxi
*/
*/
public
class
Constants
{
public
class
Constants
{
...
...
whatsmars-common/src/test/java/org/hongxi/java/net/TCPClient.java
浏览文件 @
683f2827
...
@@ -5,6 +5,9 @@ import java.io.IOException;
...
@@ -5,6 +5,9 @@ import java.io.IOException;
import
java.net.Socket
;
import
java.net.Socket
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
TCPClient
{
public
class
TCPClient
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
whatsmars-common/src/test/java/org/hongxi/java/net/TCPServer.java
浏览文件 @
683f2827
...
@@ -6,6 +6,9 @@ import java.net.BindException;
...
@@ -6,6 +6,9 @@ import java.net.BindException;
import
java.net.ServerSocket
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.Socket
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
TCPServer
{
public
class
TCPServer
{
boolean
started
;
boolean
started
;
ServerSocket
ss
;
ServerSocket
ss
;
...
...
whatsmars-common/src/test/java/org/hongxi/java/net/UDPClient.java
浏览文件 @
683f2827
...
@@ -7,6 +7,9 @@ import java.net.DatagramPacket;
...
@@ -7,6 +7,9 @@ import java.net.DatagramPacket;
import
java.net.DatagramSocket
;
import
java.net.DatagramSocket
;
import
java.net.InetSocketAddress
;
import
java.net.InetSocketAddress
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
UDPClient
{
public
class
UDPClient
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
{
try
{
...
...
whatsmars-common/src/test/java/org/hongxi/java/net/UDPServer.java
浏览文件 @
683f2827
...
@@ -6,6 +6,9 @@ import java.io.IOException;
...
@@ -6,6 +6,9 @@ import java.io.IOException;
import
java.net.DatagramPacket
;
import
java.net.DatagramPacket
;
import
java.net.DatagramSocket
;
import
java.net.DatagramSocket
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
UDPServer
{
public
class
UDPServer
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
{
try
{
...
...
whatsmars-common/src/test/java/org/hongxi/java/nio/MappedFileTest.java
浏览文件 @
683f2827
...
@@ -4,6 +4,9 @@ import java.io.RandomAccessFile;
...
@@ -4,6 +4,9 @@ import java.io.RandomAccessFile;
import
java.nio.MappedByteBuffer
;
import
java.nio.MappedByteBuffer
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileChannel
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
MappedFileTest
{
public
class
MappedFileTest
{
static
private
final
int
start
=
0
;
static
private
final
int
start
=
0
;
static
private
final
int
size
=
1024
;
static
private
final
int
size
=
1024
;
...
...
whatsmars-common/src/test/java/org/hongxi/java/nio/MultiPortEcho.java
浏览文件 @
683f2827
...
@@ -11,6 +11,9 @@ import java.nio.channels.SocketChannel;
...
@@ -11,6 +11,9 @@ import java.nio.channels.SocketChannel;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Set
;
import
java.util.Set
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
MultiPortEcho
{
public
class
MultiPortEcho
{
private
int
ports
[];
private
int
ports
[];
private
ByteBuffer
echoBuffer
=
ByteBuffer
.
allocate
(
1024
);
private
ByteBuffer
echoBuffer
=
ByteBuffer
.
allocate
(
1024
);
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/Java8Test.java
浏览文件 @
683f2827
...
@@ -9,6 +9,9 @@ import java.nio.charset.StandardCharsets;
...
@@ -9,6 +9,9 @@ import java.nio.charset.StandardCharsets;
import
java.time.*
;
import
java.time.*
;
import
java.util.Base64
;
import
java.util.Base64
;
/**
* Created by javahongxi on 2018/1/2.
*/
public
class
Java8Test
{
public
class
Java8Test
{
@Test
@Test
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CallableTest.java
浏览文件 @
683f2827
...
@@ -5,14 +5,13 @@ import java.util.concurrent.Executors;
...
@@ -5,14 +5,13 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
/**
/**
* Created on 2019/8/8.
* @author shenhongxi 2019/8/8
*
* @author shenhongxi
*/
*/
public
class
CallableTest
{
public
class
CallableTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
// submit(Callable<T>)
Future
<
String
>
future
=
executorService
.
submit
(()
->
{
Future
<
String
>
future
=
executorService
.
submit
(()
->
{
Thread
.
sleep
(
2000
);
Thread
.
sleep
(
2000
);
return
"hello"
;
return
"hello"
;
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CompletionServiceTest.java
浏览文件 @
683f2827
...
@@ -11,6 +11,8 @@ public class CompletionServiceTest {
...
@@ -11,6 +11,8 @@ public class CompletionServiceTest {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
10
);
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
10
);
CompletionService
<
Integer
>
completionService
=
new
ExecutorCompletionService
<>(
executor
);
CompletionService
<
Integer
>
completionService
=
new
ExecutorCompletionService
<>(
executor
);
// produce
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
final
int
seq
=
i
+
1
;
final
int
seq
=
i
+
1
;
completionService
.
submit
(()
->
{
completionService
.
submit
(()
->
{
...
@@ -18,6 +20,8 @@ public class CompletionServiceTest {
...
@@ -18,6 +20,8 @@ public class CompletionServiceTest {
return
seq
;
return
seq
;
});
});
}
}
// consume
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
try
{
try
{
System
.
out
.
println
(
completionService
.
take
().
get
());
System
.
out
.
println
(
completionService
.
take
().
get
());
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CountDownLatchTest.java
浏览文件 @
683f2827
...
@@ -3,9 +3,7 @@ package org.hongxi.java.util.concurrent;
...
@@ -3,9 +3,7 @@ package org.hongxi.java.util.concurrent;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.CountDownLatch
;
/**
/**
* Created on 2019/8/11.
* @author shenhongxi 2019/8/11
*
* @author shenhongxi
*
*
* @see JoinTest
* @see JoinTest
* @see InvokeAllTest
* @see InvokeAllTest
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/CyclicBarrierTest.java
浏览文件 @
683f2827
...
@@ -4,11 +4,14 @@ import java.util.concurrent.CyclicBarrier;
...
@@ -4,11 +4,14 @@ import java.util.concurrent.CyclicBarrier;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
/**
* @author shenhongxi 2019/8/11
*/
public
class
CyclicBarrierTest
{
public
class
CyclicBarrierTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
final
CyclicBarrier
cb
=
new
CyclicBarrier
(
3
);
final
CyclicBarrier
barrier
=
new
CyclicBarrier
(
3
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
executorService
.
execute
(()
->
{
executorService
.
execute
(()
->
{
try
{
try
{
...
@@ -16,30 +19,31 @@ public class CyclicBarrierTest {
...
@@ -16,30 +19,31 @@ public class CyclicBarrierTest {
System
.
out
.
println
(
"线程"
System
.
out
.
println
(
"线程"
+
Thread
.
currentThread
().
getName
()
+
Thread
.
currentThread
().
getName
()
+
"即将到达集合地点1,当前已有"
+
"即将到达集合地点1,当前已有"
+
(
cb
.
getNumberWaiting
()
+
1
)
+
(
barrier
.
getNumberWaiting
()
+
1
)
+
"个已经到达,"
+
"个已经到达,"
+
(
cb
.
getNumberWaiting
()
==
2
?
"都到齐了,继续走啊"
+
(
barrier
.
getNumberWaiting
()
==
2
?
"都到齐了,继续走啊"
:
"正在等候"
));
:
"正在等候"
));
cb
.
await
();
barrier
.
await
();
Thread
.
sleep
((
long
)
(
Math
.
random
()
*
10000
));
Thread
.
sleep
((
long
)
(
Math
.
random
()
*
10000
));
System
.
out
.
println
(
"线程"
System
.
out
.
println
(
"线程"
+
Thread
.
currentThread
().
getName
()
+
Thread
.
currentThread
().
getName
()
+
"即将到达集合地点2,当前已有"
+
"即将到达集合地点2,当前已有"
+
(
cb
.
getNumberWaiting
()
+
1
)
+
(
barrier
.
getNumberWaiting
()
+
1
)
+
"个已经到达,"
+
"个已经到达,"
+
(
cb
.
getNumberWaiting
()
==
2
?
"都到齐了,继续走啊"
+
(
barrier
.
getNumberWaiting
()
==
2
?
"都到齐了,继续走啊"
:
"正在等候"
));
:
"正在等候"
));
cb
.
await
();
barrier
.
await
();
Thread
.
sleep
((
long
)
(
Math
.
random
()
*
10000
));
Thread
.
sleep
((
long
)
(
Math
.
random
()
*
10000
));
System
.
out
.
println
(
"线程"
System
.
out
.
println
(
"线程"
+
Thread
.
currentThread
().
getName
()
+
Thread
.
currentThread
().
getName
()
+
"即将到达集合地点3,当前已有"
+
"即将到达集合地点3,当前已有"
+
(
cb
.
getNumberWaiting
()
+
1
)
+
(
barrier
.
getNumberWaiting
()
+
1
)
+
"个已经到达,"
+
"个已经到达,"
+
(
cb
.
getNumberWaiting
()
==
2
?
"都到齐了,继续走啊"
+
(
barrier
.
getNumberWaiting
()
==
2
?
"都到齐了,继续走啊"
:
"正在等候"
));
:
"正在等候"
));
cb
.
await
();
barrier
.
await
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/ExchangerTest.java
浏览文件 @
683f2827
...
@@ -4,6 +4,9 @@ import java.util.concurrent.Exchanger;
...
@@ -4,6 +4,9 @@ import java.util.concurrent.Exchanger;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
/**
* @author shenhongxi 2019/8/11
*/
public
class
ExchangerTest
{
public
class
ExchangerTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/FutureTaskTest.java
浏览文件 @
683f2827
...
@@ -5,15 +5,14 @@ import java.util.concurrent.Executors;
...
@@ -5,15 +5,14 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.FutureTask
;
import
java.util.concurrent.FutureTask
;
/**
/**
* Created on 2019/8/8.
* @author shenhongxi 2019/8/8
*
* @author shenhongxi
*/
*/
public
class
FutureTaskTest
{
public
class
FutureTaskTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
ExecutorService
executorService
=
Executors
.
newCachedThreadPool
();
FutureTask
<
String
>
task
=
new
FutureTask
<>(()
->
"hello"
);
FutureTask
<
String
>
task
=
new
FutureTask
<>(()
->
"hello"
);
// submit(Runnable)
executorService
.
submit
(
task
);
executorService
.
submit
(
task
);
FutureTask
<
String
>
task2
=
new
FutureTask
<>(()
->
FutureTask
<
String
>
task2
=
new
FutureTask
<>(()
->
System
.
out
.
println
(
"..."
),
"world"
);
System
.
out
.
println
(
"..."
),
"world"
);
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/InterruptTest.java
浏览文件 @
683f2827
package
org.hongxi.java.util.concurrent
;
package
org.hongxi.java.util.concurrent
;
/**
/**
* Created on 2019/8/10.
* @author shenhongxi 2019/8/10
*
* @author shenhongxi
*
*
* @see InterruptedTest
* @see InterruptedTest
*/
*/
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/InterruptedTest.java
浏览文件 @
683f2827
package
org.hongxi.java.util.concurrent
;
package
org.hongxi.java.util.concurrent
;
/**
/**
* Created on 2019/8/10.
* @author shenhongxi 2019/8/10
*
* @author shenhongxi
*/
*/
public
class
InterruptedTest
{
public
class
InterruptedTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Thread
t
=
new
Thread
(()
->
{
Thread
t
=
new
Thread
(()
->
{
System
.
out
.
println
(
Thread
.
interrupted
());
// currentThread().isInterrupted(true);
// currentThread().isInterrupted(true);
System
.
out
.
println
(
Thread
.
interrupted
());
System
.
out
.
println
(
Thread
.
interrupted
());
// true
System
.
out
.
println
(
Thread
.
interrupted
());
// false
});
});
t
.
start
();
t
.
start
();
t
.
interrupt
();
// Just to set the interrupt flag
t
.
interrupt
();
// Just to set the interrupt flag
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/InvokeAllTest.java
浏览文件 @
683f2827
...
@@ -6,9 +6,7 @@ import java.util.List;
...
@@ -6,9 +6,7 @@ import java.util.List;
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
/**
/**
* Created on 2019/8/11.
* @author shenhongxi 2019/8/11
*
* @author shenhongxi
*/
*/
public
class
InvokeAllTest
{
public
class
InvokeAllTest
{
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/ReentrantLockTest.java
浏览文件 @
683f2827
...
@@ -4,6 +4,9 @@ import java.util.concurrent.locks.Condition;
...
@@ -4,6 +4,9 @@ import java.util.concurrent.locks.Condition;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.ReentrantLock
;
import
java.util.concurrent.locks.ReentrantLock
;
/**
* @author shenhongxi 2019/8/11
*/
public
class
ReentrantLockTest
{
public
class
ReentrantLockTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/RunnableTest.java
浏览文件 @
683f2827
...
@@ -6,9 +6,7 @@ import java.util.concurrent.Future;
...
@@ -6,9 +6,7 @@ import java.util.concurrent.Future;
import
java.util.stream.IntStream
;
import
java.util.stream.IntStream
;
/**
/**
* Created on 2019/8/8.
* @author shenhongxi 2019/8/8
*
* @author shenhongxi
*
*
* @see CallableTest
* @see CallableTest
* @see FutureTaskTest
* @see FutureTaskTest
...
...
whatsmars-common/src/test/java/org/hongxi/java/util/concurrent/ScheduleTest.java
浏览文件 @
683f2827
...
@@ -7,9 +7,7 @@ import java.util.concurrent.ScheduledFuture;
...
@@ -7,9 +7,7 @@ import java.util.concurrent.ScheduledFuture;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
* Created on 2019/8/10.
* @author shenhongxi 2019/8/10
*
* @author shenhongxi
*/
*/
public
class
ScheduleTest
{
public
class
ScheduleTest
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录