public class Test { public static void main(String[] args) { int a = 3; int b = a++; //a先给b赋值,所以b是3,然后再自增1,所以再输出a为4 System.out.println(a); //输出结果 4 in ...
分类:
其他好文 时间:
2021-04-15 12:49:34
阅读次数:
0
1:对synchronized的理解: 1.1 :假设t1和t2并发,开始执行时肯定有先有后 1.2:假设t1先执行,看到synchronized这个时候自动找“后面的共享对象”的对象锁,找到后并占有锁,然后执行后面同步代码块,在程序执行过程一直都是占有这把锁,直到同步代码块结束,锁才释放。 1.3 ...
分类:
其他好文 时间:
2021-04-15 12:38:55
阅读次数:
0
package ShunXuDome;public class forDOme05 { public static void main(String[] args) { int[]numbers={10,20,30,40,50};//定义了一个数组 for (int i = 0; i < 5; i+ ...
分类:
其他好文 时间:
2021-04-15 12:23:41
阅读次数:
0
在 Java 程序中,我们可以利用 synchronized 关键字来对程序进行加锁。它既可以用来声明一个 synchronized 代码块,也可以直接标记静态方法或者实例方法。 当声明 synchronized 代码块时,编译而成的字节码将包含 monitorenter 和 monitorexit ...
分类:
编程语言 时间:
2021-04-15 12:06:23
阅读次数:
0
事件监听 当某个事件发生,会产生什么? public class Demo01 { public static void main(String[] args) { //按下按钮,触发事件 Frame frame = new Frame(); Button button = new Button() ...
分类:
其他好文 时间:
2021-04-14 12:40:04
阅读次数:
0
增强for循环 public class ForDemo{ public static void main(String[] args){ int[] numbers = {10,20,30,40,50}; //遍历数组元素 for(int x:numbers){ System.out.printl ...
分类:
编程语言 时间:
2021-04-14 12:36:49
阅读次数:
0
一、代码展示 <template> ... <div class="loading-animation-box" > <img class="loading-animation" width="26" height="28" src="../../../static/images/balabla.p ...
分类:
Web程序 时间:
2021-04-14 12:20:55
阅读次数:
0
package com.kuang.struct; public class TestDemo { public static void main(String[] args) { //打印三角形 5行 for (int i = 1; i <= 5; i++) { for (int j = 5; j ...
分类:
其他好文 时间:
2021-04-14 12:09:53
阅读次数:
0
// 1.Java方法 public static void main (String args[]){ int res = sum(1, 2); // int res = HelloWorld.sum(1, 2); System.out.println(res); } // 求和 public s ...
分类:
编程语言 时间:
2021-04-14 12:05:41
阅读次数:
0
先来个单例模式的线程安全代码 package basic.single; public class SingleTon { private SingleTon(){ System.out.println(Thread.currentThread().getName()); } private sta ...
分类:
其他好文 时间:
2021-04-14 11:58:53
阅读次数:
0