
thread
kong-kong
记录流水账
展开
-
源码之Thread.interrupted()
Thread.interrupted()调用t.interrupt()后,第一次返回true, 第2次及之后都返回falsejdk源码其实都是空方法public static boolean interrupted() { return currentThread().isInterrupted(true); // ClearInterrupted}private native boolean isInterrupted(boolean ClearInterrupted);JVM_原创 2021-06-28 22:33:35 · 363 阅读 · 0 评论 -
thread state
public enum State { /** * Thread state for a thread which has not yet started. */ NEW, /** * Thread state for a runnable thread. A thread in the ru转载 2014-11-07 14:04:30 · 690 阅读 · 0 评论 -
Interrupting a thread
The Thread class has an attribute that stores a boolean value indicating whether thethread has been interrupted or not. When you call the interrupt() method of a thread,you set that attribute to true.翻译 2014-11-10 14:41:11 · 568 阅读 · 0 评论 -
thread join demo
/** * Waits for this thread to die. * * An invocation of this method behaves in exactly the same * way as the invocation * * * {@linkplain #join(long) join}原创 2014-11-05 14:32:03 · 527 阅读 · 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 评论 -
循环报错: 远程主机强迫关闭了一个现有的连接
客户端终止后,服务端一直循环报java.io.IOException: 远程主机强迫关闭了一个现有的连接。原始代码private void read(SocketChannel channel,SelectionKey key) throws Exception { ByteBuffer buffer = ByteBuffer.allocate(1024); //创建...原创 2019-06-13 11:16:39 · 6061 阅读 · 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 评论