Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
68cd84c8
Commit
68cd84c8
authored
Nov 24, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改日志打印功能,打印更加详细的日志
parent
91d711d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
WeakHashMapTest.java
yzg-util-base/src/test/java/base/WeakHashMapTest.java
+38
-0
No files found.
yzg-util-base/src/test/java/base/WeakHashMapTest.java
0 → 100644
View file @
68cd84c8
package
base
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
org.junit.Test
;
import
sun.misc.GC
;
import
java.util.Map
;
import
java.util.WeakHashMap
;
public
class
WeakHashMapTest
{
public
static
class
MyKey
{
}
@Test
public
void
test
()
throws
InterruptedException
{
Map
<
MyKey
,
Integer
>
map
=
new
WeakHashMap
<>();
test1
(
map
);
System
.
out
.
println
(
map
.
size
());
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
while
(
true
){
System
.
gc
();
System
.
out
.
println
(
map
.
size
());
ThreadHelper
.
sleep
(
100
);
}
}
});
thread
.
start
();
thread
.
join
();
}
private
void
test1
(
Map
<
MyKey
,
Integer
>
map
){
map
.
put
(
new
MyKey
(),
1
);
}
}
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