This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ch.qos.logback.classic.Level; | |
import ch.qos.logback.classic.LoggerContext; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.util.List; | |
/** | |
* change log level at runtime | |
* Created by nkcoder on 10/8/16. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nkcoder.module.javatest.concurrent; | |
import java.util.concurrent.*; | |
import java.util.concurrent.atomic.AtomicLong; | |
import java.util.logging.Logger; | |
/** | |
* created by daniel at 2/5/17 22:54 | |
*/ | |
public class TimingThreadPool extends ThreadPoolExecutor { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nkcoder.module.javatest.concurrent; | |
import java.util.concurrent.*; | |
import java.util.concurrent.atomic.AtomicLong; | |
import java.util.logging.Logger; | |
/** | |
* created by daniel at 2/5/17 22:54 | |
*/ | |
public class TimingThreadPool extends ThreadPoolExecutor { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nkcoder.module.javatest.concurrent; | |
import java.util.concurrent.CompletableFuture; | |
/** | |
* {@link: http://www.deadcoderising.com/java8-writing-asynchronous-code-with-completablefuture/} | |
* Created by nkcoder on 12/21/16. | |
*/ | |
public class CompletableFutureTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nkcoder.module.javatest.concurrent; | |
import java.util.concurrent.*; | |
/** | |
* Created by nkcoder on 12/21/16. | |
*/ | |
public class CompletionServiceTest { | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nkcoder.module.javatest.concurrent; | |
import java.util.concurrent.Semaphore; | |
import java.util.concurrent.TimeUnit; | |
/** | |
* created by daniel at 12/16/16 08:33 | |
*/ | |
public class SemaphoreTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nkcoder.module.javatest.concurrent; | |
import java.time.Duration; | |
import java.time.Instant; | |
import java.util.Random; | |
import java.util.concurrent.CountDownLatch; | |
/** | |
* created by daniel at 12/15/16 21:45 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.nio.file.*; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.concurrent.*; | |
import java.util.stream.Stream; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.yousharp.designpattern.singleton; | |
/** | |
* 通过内部类实现单例模式,只有需要时才会创建示例; | |
* 如果需要使用单例模式,强烈推荐这种实现方式。 | |
* User: Daniel | |
* Date: 13-12-5 | |
* Time: 下午10:04 | |
*/ | |
public class InnerClassSingleton { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DeadLockDemo { | |
public static void main(String[] args) { | |
Object o1 = new Object(); | |
Object o2 = new Object(); | |
Runnable r1 = () -> { | |
synchronized(o1) { | |
try { | |
Thread.sleep(3000); | |
} catch (Exception e) { |
NewerOlder