Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HTAnticollision
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马乐
HTAnticollision
Commits
2144d4c6
Commit
2144d4c6
authored
Mar 07, 2023
by
马乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修改线程命名方式
parent
f848c1da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
TcpManager.kt
...src/main/java/com/waytous/anticollision/tcp/TcpManager.kt
+1
-1
NamedThreadFactory.kt
...ava/com/waytous/anticollision/utils/NamedThreadFactory.kt
+3
-2
No files found.
app/src/main/java/com/waytous/anticollision/tcp/TcpManager.kt
View file @
2144d4c6
...
@@ -74,7 +74,7 @@ internal class TcpManager(
...
@@ -74,7 +74,7 @@ internal class TcpManager(
* 发送线程
* 发送线程
* */
* */
private
val
sendExecutors
:
ExecutorService
by
lazy
{
private
val
sendExecutors
:
ExecutorService
by
lazy
{
Executors
.
newCachedThreadPool
(
NamedThreadFactory
(
"Send"
))
Executors
.
newCachedThreadPool
(
NamedThreadFactory
(
"Send"
,
false
))
}
}
/**
/**
...
...
app/src/main/java/com/waytous/anticollision/utils/NamedThreadFactory.kt
View file @
2144d4c6
...
@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicInteger
...
@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicInteger
* 现场创建工厂
* 现场创建工厂
* @param prefix
* @param prefix
* */
* */
class
NamedThreadFactory
(
private
val
prefix
:
String
)
:
ThreadFactory
{
class
NamedThreadFactory
(
private
val
prefix
:
String
,
private
val
ignoreThreadNumber
:
Boolean
=
true
)
:
ThreadFactory
{
private
val
threadNumber
by
lazy
{
private
val
threadNumber
by
lazy
{
AtomicInteger
(
1
)
AtomicInteger
(
1
)
...
@@ -16,6 +16,6 @@ class NamedThreadFactory(private val prefix: String) : ThreadFactory {
...
@@ -16,6 +16,6 @@ class NamedThreadFactory(private val prefix: String) : ThreadFactory {
override
fun
newThread
(
r
:
Runnable
?):
Thread
=
Thread
(
override
fun
newThread
(
r
:
Runnable
?):
Thread
=
Thread
(
null
,
null
,
r
,
r
,
if
(
prefix
==
"Receive"
||
prefix
==
"Parser"
)
prefix
else
"$prefix-${threadNumber.getAndIncrement()}"
if
(
ignoreThreadNumber
)
prefix
else
"$prefix-${threadNumber.getAndIncrement()}"
)
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment