Auto commit

上级 5b0ce43e
package com.shizhuang.duapp.push;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.shizhuang.duapp.channel.dto.priority.PrioritySeqDTO;
import com.shizhuang.duapp.channel.pool.PriorityThreadPoolExecutor;
import java.util.concurrent.*;
/**
* Created by wu.guofeng on 2023/5/5 下午4:26
*/
public class ThreadLocalTest {
public static InheritableThreadLocal<String> threadLocal = new InheritableThreadLocal<String>();
static ExecutorService executorService = Executors.newFixedThreadPool(1);
public static void main(String[] args){
threadLocal.set("china");
System.out.println("thread: " + Thread.currentThread().getName() + " country: " + threadLocal.get());
executorService.submit(()->{
System.out.println("thread1: " + Thread.currentThread().getName() + " country: " + threadLocal.get());
threadLocal.set("china2");
});
threadLocal.set("china3");
executorService.submit(()->{
System.out.println("thread2: " + Thread.currentThread().getName() + " country: " + threadLocal.get());
});
/*ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("testThreadLocal").build();
PriorityThreadPoolExecutor priorityThreadPoolExecutor = new PriorityThreadPoolExecutor(1, 1,
0L, TimeUnit.MICROSECONDS, threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
priorityThreadPoolExecutor.submit(()->{
System.out.println("thread: " + Thread.currentThread().getName());
}, PrioritySeqDTO.init());*/
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册