package com.thread.test.thread; /** * Created by windwant on 2016/6/3. */ public class MyTestDeadLock { public void run() { MyThread mt = new MyThread(); new Thread(mt, "zhangsan").start(); new Thread(mt, "lisi").start(); } class MyThr…
java并发之固定对象与实例 Immutable Objects An object is considered immutable if its state cannot change after it is constructed. Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects…
14.5.5.1 An InnoDB Deadlock Example 一个InnoDB 死锁实例 下面的例子演示了一个错误可以发生当一个lock 请求会导致一个死锁,例子设计2个客户端,A和B: Jekins:/root# mysql -uroot -p1234567 -e"SHOW ENGINE INNODB STATUS\G;" | grep -i dead Warning: Using a password on the command line interface can b…
在上篇博客中分析了hashmap的用法,详情查看java并发之hashmap 本篇博客重点分析下hashmap的源码(基于JDK1.8) 一.成员变量 HashMap有以下主要的成员变量 /** * The default initial capacity - MUST be a power of two. 默认初始容量 */ static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 /** * The maximum capa…
在Java笔试中,构造方法.实例初始化.静态初始化执行顺序,是一个经常被考察的知识点. 像下面的这道题(刚刚刷题做到,虽然做对了,但是还是想整理一下) 运行下面的代码,输出的结果是... class A { public A() { System.out.println("class A"); } { System.out.println("I'm A class"); } static { System.out.println("class A stat…
Java实现一个死锁 有一个藏宝图(treasureMapFragment)分成两份jack持有treasureMapFragment1残片1,json持有残片2.jack要求必须先看到json的残图才给json看自己的残图,而json要求必须先看到jack的残图才给jack看自己的残图.双方都在请求对方持有的资源但是不释放自己手里的资源,就形成了死锁. package yu; public class DeadLock { public static void main(String[] ar…