Skip to content

Commit f40ed34

Browse files
author
chenzhuo
committed
跑数据~~~
1 parent 9b42740 commit f40ed34

17 files changed

Lines changed: 299 additions & 11 deletions

File tree

.idea/compiler.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/basics/ClassLoaderTest/classPathTest/ClassLoaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public ClassLoaderTest(String rootDir){
2121
* @throws ClassNotFoundException
2222
*/
2323
@Override
24-
protected Class<?> findClass(String name) throws ClassNotFoundException {
24+
public Class<?> findClass(String name) throws ClassNotFoundException {
2525
byte[] classData = getClassData(name);
2626
if(null == classData){
2727
throw new ClassNotFoundException();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.basics.Lock.Synchronized;
2+
3+
import java.util.concurrent.locks.Lock;
4+
import java.util.concurrent.locks.ReentrantLock;
5+
6+
/**
7+
* @ClassName: LockFreeTest
8+
* @Description TODO
9+
* @Date 2019/1/24 14:19
10+
* @Created by chenzhuo
11+
**/
12+
public class LockFreeTest {
13+
private static Lock lock = new ReentrantLock(true);
14+
15+
/**
16+
* stack=1, locals=1, args_size=1
17+
* 0: getstatic #2 // Field lock:Ljava/util/concurrent/locks/Lock;
18+
* 3: invokeinterface #3, 1 // InterfaceMethod java/util/concurrent/locks/Lock.lock:()V
19+
* 8: invokestatic #4 // Method test:()V
20+
* 11: getstatic #2 // Field lock:Ljava/util/concurrent/locks/Lock;
21+
* 14: invokeinterface #5, 1 // InterfaceMethod java/util/concurrent/locks/Lock.unlock:()V
22+
* 19: return
23+
*
24+
* @param args
25+
*/
26+
public static void main(String[] args) {
27+
lock.lock();
28+
test();
29+
lock.unlock();
30+
31+
}
32+
33+
public static void test() {
34+
System.out.println("lock free Test");
35+
}
36+
}

src/main/java/com/basics/Lock/Synchronized/SynchronizedTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*
88
**/
99
public class SynchronizedTest {
10+
11+
private static Object object = new Object();
1012
/**
1113
* public static void main(java.lang.String[]);
1214
* descriptor: ([Ljava/lang/String;)V
@@ -36,6 +38,14 @@ public static void main(String[] args) {
3638
synchronized (SynchronizedTest.class){
3739
new SynchronizedTest().m();
3840
}
41+
SynchronizedTest synchronizedTest = new SynchronizedTest();
42+
synchronizedTest.m();
43+
}
44+
45+
private void test(){
46+
synchronized (object){
47+
System.out.println("hello ");
48+
}
3949
}
4050

4151
/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.basics.concurrent;
2+
3+
import java.util.concurrent.*;
4+
5+
/**
6+
* @Description TODO
7+
* @Date 2019/4/1 12:38
8+
* @Created by chenzhuo
9+
**/
10+
public class SemaphoreTest {
11+
private final static Semaphore semaphore = new Semaphore(1, true);
12+
13+
public static void main(String[] args) {
14+
15+
ThreadPoolExecutor threadPoolExecutor = new
16+
ThreadPoolExecutor(10, 10, 0, TimeUnit.SECONDS,
17+
new LinkedBlockingQueue<>(100));
18+
SemaphoreThread semaphoreThread = new SemaphoreThread();
19+
threadPoolExecutor.execute(semaphoreThread);
20+
21+
22+
}
23+
24+
private static class SemaphoreThread extends Thread {
25+
26+
@Override
27+
public void run() {
28+
try {
29+
semaphore.acquire();
30+
System.out.println("time:" + System.currentTimeMillis());
31+
} catch (InterruptedException e) {
32+
e.printStackTrace();
33+
} finally {
34+
semaphore.release();
35+
}
36+
37+
}
38+
}
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.basics.util.map;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
/**
7+
* @author by chenzhuo
8+
* @Description hashMap learn
9+
* @Date 2019/4/11 16:32
10+
**/
11+
public class HashMapTest {
12+
13+
public static void main(String[] args) {
14+
Map<String,String> map = new HashMap<>();
15+
map.put("cc","c");
16+
map.put("c1","c");
17+
map.put("c2","c");
18+
map.put("c3","c");
19+
map.put("c4","c");
20+
map.put("c5","c");
21+
map.put("c6","c");
22+
map.put("c7","c");
23+
map.put("c8","c");
24+
map.put("c9","c");
25+
map.put("c10","c");
26+
map.put("c11","c");
27+
map.put("c12","c");
28+
29+
}
30+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @Description 集合类
3+
* @Date 2019/4/11 16:31
4+
* @author by chenzhuo
5+
**/
6+
package com.basics.util;

src/main/java/com/concurrent/volatileLearn/VolatileOne.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ public static void main(String[] args) {
2121
}
2222

2323
private void showDown() {
24-
SHOW_DOWN_STATUS = true;
24+
SHOW_DOWN_STATUS = false;
2525
}
2626

2727
/**
2828
这里在循环外调用showDown
2929
*/
3030
public void doWorker() {
31-
while (!SHOW_DOWN_STATUS) {
31+
while (SHOW_DOWN_STATUS) {
3232
runTest();
3333
}
3434
}

src/main/java/com/jdk8/lmb/DoSoming.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.jdk8.lmb;
22

3-
import com.jdk8.lmb.lam_interface.CFucntion;
3+
import com.jdk8.lmb.lam_interface.CFunction;
44
import com.jdk8.lmb.lam_interface.User;
55

6-
import java.util.Comparator;
7-
86
/**
97
* @ClassName DoSoming
108
* @Despacito TODO
@@ -21,12 +19,12 @@ String startsWith(String s) {
2119

2220
public static void main(String[] args) {
2321
DoSoming soming = new DoSoming();
24-
CFucntion<String,String> cFucntion = soming::startsWith;
22+
CFunction<String,String> cFucntion = soming::startsWith;
2523
String sing = cFucntion.using("Demons");
2624
System.out.println("sing : "+sing);
2725
System.out.println("classe:"+ cFucntion.getClass().getInterfaces()[0]);
2826
User user = new User();
29-
CFucntion<User,String> fucntion = User::getUserName;
27+
CFunction<User,String> fucntion = User::getUserName;
3028
fucntion.using(user);
3129

3230

0 commit comments

Comments
 (0)