Skip to content

Commit

Permalink
write a line into test.file
Browse files Browse the repository at this point in the history
  • Loading branch information
huifer committed Jan 19, 2025
1 parent c03951b commit 3a69c7f
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 0 deletions.
88 changes: 88 additions & 0 deletions docs/spring/cs7a6c26c0-d606-11ef-9488-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.huifer.jdk.thread;

import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
* <p>Title : SpringLoad2 </p>
* <p>Description : </p>
*
* @author huifer
* @date 2019-05-27
*/
public class SpringLoad2 {

public static void main(String[] args) {
SpringLoad2 springLoad2 = new SpringLoad2();
springLoad2.loadProject();
}

public void loadProject() {
try {
long start = System.currentTimeMillis();
ExecutorService service = Executors.newFixedThreadPool(3);
CompletionService completionService = new ExecutorCompletionService(service);

completionService.submit(this::loadSpringMvc, null);
completionService.submit(this::loadMyBatis, null);
completionService.submit(this::loadSpring, null);


int count = 0;
while (count < 3) {
if (completionService.poll() != null) {
count++;
}
}

service.shutdown();
System.out.println(System.currentTimeMillis() - start);

} catch (Exception e) {
e.printStackTrace();

}
}


private void loadSpringMvc() {
loadXML("spring-mvc.xml", 1);
}


private void loadMyBatis() {
loadXML("mybatis.xml", 2);
}

private void loadSpring() {
loadXML("spring.xml", 3);
}


/***
* 加载文件
* @param xml
* @param loadSec
*/
private void loadXML(String xml, int loadSec) {
try {
long startTime = System.currentTimeMillis();
long milliseconds = TimeUnit.SECONDS.toMillis(loadSec);
Thread.sleep(milliseconds);
long endTime = System.currentTimeMillis();

System.out.printf("[线程 : %s] 加载%s 耗时: %d 毫秒\n",
Thread.currentThread().getName(),
xml,
endTime - startTime
);
} catch (Exception e) {
e.printStackTrace();

}
}

}
49 changes: 49 additions & 0 deletions docs/spring/cs7abf0fc0-d606-11ef-9488-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.huifer.concurrence.ch2;

/**
* <p>Title : StarveDemo </p>
* <p>Description : 饿死</p>
*
* @author huifer
* @date 2019-03-27
*/
public class StarveDemo {

private static Object sharedObj = new Object();

public static void main(String[] args) {

for (int i = 0; i < 5; i++) {
StarveThread progressThread = new StarveThread("线程-" + i);
progressThread.start();
}

}


private static class StarveThread extends Thread {

public StarveThread(String name) {
super(name);
}

@Override
public void run() {
int c = 0;
while (true) {
synchronized (sharedObj) {
if (c == 10) {
c = 0;
}
++c;
System.out.println(Thread.currentThread().getName() + "值:" + c);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
}
73 changes: 73 additions & 0 deletions docs/spring/cs7b1574fa-d606-11ef-9488-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright 2009-2019 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.submitted.call_setters_on_nulls;

import org.apache.ibatis.BaseDataTest;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.Reader;
import java.util.Map;

class DoNotCallSettersOnNullsTest {

private static SqlSessionFactory sqlSessionFactory;

@BeforeAll
static void setUp() throws Exception {
// create a SqlSessionFactory
try (Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/call_setters_on_nulls/mybatis-config-2.xml")) {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
}

// populate in-memory database
BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(),
"org/apache/ibatis/submitted/call_setters_on_nulls/CreateDB.sql");
}

@Test
void shouldCallNullOnMappedProperty() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
User user = mapper.getUserMapped(1);
Assertions.assertFalse(user.nullReceived);
}
}

@Test
void shouldCallNullOnAutomaticMapping() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
User user = mapper.getUserUnmapped(1);
Assertions.assertFalse(user.nullReceived);
}
}

@Test
void shouldCallNullOnMap() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
Map user = mapper.getUserInMap(1);
Assertions.assertFalse(user.containsKey("NAME"));
}
}

}
23 changes: 23 additions & 0 deletions docs/spring/cs7b62c098-d606-11ef-9488-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.huifer.jdk.jdk8.stearm;

import java.util.stream.Stream;

/**
* 描述:
*
* @author huifer
* @date 2019-06-16
*/
public class Demo05 {
public static void main(String[] args) {
Stream<Integer> integerStream = Stream.iterate(1, item -> item + 1).limit(10);

int sum = integerStream.filter(integer -> integer > 2).mapToInt(x -> x * 2).skip(2).limit(2).sum();
System.out.println(sum);

// IntSummaryStatistics intSummaryStatistics = distinct.filter(integer -> integer > 2).mapToInt(x -> x * 2).summaryStatistics();
// System.out.println(intSummaryStatistics.getMin());
//

}
}
24 changes: 24 additions & 0 deletions docs/spring/cs7bab3710-d606-11ef-9488-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2009-2015 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ibatis.executor.loader;

/**
* @author Eduardo Macarron
*/
@Deprecated
public final class JavassistProxyFactory extends org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory {
/* no-op */
}
4 changes: 4 additions & 0 deletions docs/spring/cs7bf33a10-d606-11ef-9488-acde48001122.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.huifer.rbac.entity.req.resource.menu;

public class MenuEditorReq {
}
Loading

0 comments on commit 3a69c7f

Please sign in to comment.