
concurrent
kong-kong
记录流水账
展开
-
源码之Thread.interrupted()
Thread.interrupted() 调用t.interrupt()后,第一次返回true, 第2次及之后都返回false jdk源码 其实都是空方法 public static boolean interrupted() { return currentThread().isInterrupted(true); // ClearInterrupted } private native boolean isInterrupted(boolean ClearInterrupted); JVM_原创 2021-06-28 22:33:35 · 363 阅读 · 0 评论 -
epoll
EPool.c epollCreate JNIEXPORT jint JNICALL Java_sun_nio_ch_EPoll_epollCreate(JNIEnv *env, jclass c) { /* * epoll_create expects a size as a hint to the kernel about how to * dimension internal structures. We can't predict the size in advan原创 2021-03-04 23:03:37 · 223 阅读 · 1 评论 -
IA-32 Assembly Language Reference Manual
IA-32 IA-32 Assembly Language Reference Manual cmpxchg Compare and Exchange (cmpxchg)[486] cmpxchg{bwl} reg[8|16|32], r/m[8|16|32] Example cmpxchgb %cl, 1(%esi) cmpxchgl %edx, 4(%edi) https://docs.oracle.com/cd/E19455-01/806-3773/6jct9o0b0/index.html原创 2021-03-03 18:33:01 · 317 阅读 · 1 评论 -
compareAndSwapInt实现
compareAndSwapInt unsafe.compareAndSwapInt(this, valueOffset, expect, update) 接口定义 public final native boolean compareAndSwapInt(Object object, long offset, int expect, int update); unsafe.cpp Unsafe_CompareAndSwapInt UNSAFE_ENTRY(jboolean, Unsafe_Comp原创 2021-03-02 22:09:21 · 2432 阅读 · 1 评论 -
interrupt()、interrupted()、isInterrupted()区别
# 线程中断方法 interrupt() # interrupt()方法中断后 第一次调用interrupted(),返回true # 之后调用interrupted()返回false,除非线程重新中断 interrupted() # interrupt()调用后,isInterrupted()返回true isInterrupted() demo1 # demo1 public static void main(String[] args) throws Exception{...原创 2020-06-05 16:20:04 · 314 阅读 · 0 评论 -
ScheduledExecutorService
static ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(3, new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setDaemon(true); ..原创 2020-05-30 17:22:11 · 267 阅读 · 0 评论 -
wait sleep yield 区别
wait和sleep区别: wait()方法必须在synchronized同步块或方法中 wait()方法会释放由synchronized锁上的对象锁,而sleep()则不会 由wait()方法形成的阻塞,可以通过针对同一个对象锁的synchronized作用域调用notify/notifyAll来唤醒; 而sleep()则无法被“唤醒”,其只能定时醒来或被interrupt()方法...转载 2019-08-06 00:19:30 · 384 阅读 · 0 评论 -
java线程优先级
/** * The minimum priority that a thread can have. */ public final static int MIN_PRIORITY = 1; /** * The default priority that is assigned to a thread. */ publ...原创 2019-05-12 00:50:31 · 444 阅读 · 0 评论 -
ShutdownHook demo
#MyShutdownHook public class MyShutdownHook extends Thread{ public MyShutdownHook(String name){ super(name); } private static final MyShutdownHook myShutdownHook = new My...原创 2019-05-06 15:12:33 · 246 阅读 · 0 评论