自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 收藏
  • 关注

原创 volatile禁止指令重排

多线程环境中线程交替执行,由于编译器优化重排的存在,无法保证两个线程之间使用变量的一致性首先编译器执行指令的时候会存在指令重排的情况,以便于提高指令的执行速度。就像是考试一样,肯定是先把会的题做完再做难的题目。什么时候会发生重排,也就是两个指令之间不会存在依赖性,例如: a = 1; y = a+1。这两个语句就不会发生指令重排,因为y的值依赖a的值;但是如果是: a =1 ; y = 2 。这两个语句就会发生,因为不存在依赖。在单线程的条件下,指令重排不会影响到最终的结果,也就是数据的一致性可以得到保

2021-02-21 15:09:09 290

原创 volatile的不保证原子性

package now;import java.util.concurrent.TimeUnit;class Student{ volatile int age = 0; //此时的age加了volatile关键字修饰,volatile不保证原子性 public void addPlusPlus() { this.age++; }}/** * 验证volatile的不保证原子性 * 原子性的意思是不可分割,完整性,也就是某个线程在执行某个具

2021-02-21 13:52:46 113

原创 volatile的可见性(代码实现)

volatile的可见性(代码实现)package now;import java.sql.Time;import java.util.concurrent.TimeUnit;class Student{ int age = 0; //volatitle int age = 0; public void changeage(){ this.age = 50; }}/** * 验证volatile的可见性 * 假如 int age = 0

2021-02-21 11:47:54 297 1

原创 SpringMVC错误:org.springframework.web.servlet.DispatcherServlet noHandlerFound

https://blog.csdn.net/Mrs_Yu/article/details/87003383

2020-06-25 20:25:44 203

原创 解决maven项目创建过慢的问题

archetypeCataloginternal

2020-06-25 15:54:33 128

原创 声明式事务控制(基于纯注解)

F:\spring\day04_eesy_05anno_tx_withoutxmlAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.jd

2020-06-25 11:01:44 288

原创 声明式事务控制(基于注解加XML)

F:\spring\day04_eesy_04tx_annoAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.jdbc.core.Bea

2020-06-25 10:57:36 161

原创 声明式事务控制(基于XML)

F:\spring\day04_eesy_03tx_xmlAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import org.springframework.jdbc.core.BeanPropertyRowMapper;import org.springframework.jdbc.core.JdbcTem

2020-06-25 10:54:26 223

原创 JdbcTemplate入门(基于XML)

F:\spring\day04_eesy_01jdbctemplateAccount.javapackage com.itheima.domain;import java.io.Serializable;public class Account implements Serializable { private Integer id; private String name; private Float money; @Override public

2020-06-24 16:33:22 315

原创 AOP四种常用通知类型+环绕通知(基于注解+XML)

F:\spring\day03_eesy_05annotationAOPAccountServiceImpl.javapackage com.itheima.service.impl;import com.itheima.service.IAccountService;import org.springframework.stereotype.Service;/** * 账户的业务层实现类 */@Service("accountService")public class Account

2020-06-24 14:21:11 689

原创 AOP四种常用通知类型+环绕通知(基于XML)

F:\spring\day03_eesy_04adviceTypebean.xml<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframewor

2020-06-24 13:44:38 529

原创 AOP必要的代码(基于XML)

F:\spring\day03_eesy_03springAOPAccountServiceImpl.javapackage com.itheima.service.impl;import com.itheima.service.IAccountService;/** * 账户的业务层实现类 */public class AccountServiceImpl implements IAccountService { public void saveAccount() {

2020-06-24 13:18:17 108

原创 两种动态代理方式(基于接口和基于子类)

F:\spring\day03_eesy_02proxy基于子类的动态代理:Client.javapackage com.itheima.cglib;import com.itheima.proxy.IProducer;import net.sf.cglib.proxy.Enhancer;import net.sf.cglib.proxy.MethodInterceptor;import net.sf.cglib.proxy.MethodProxy;import java.lang.r

2020-06-24 11:34:39 278

原创 银行转账案例(事务控制)

F:\spring\day03_eesy_01accountAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import com.itheima.utils.ConnectionUtils;import org.apache.commons.dbutils.QueryRunner;import org.ap

2020-06-24 11:21:11 649

原创 简单的IOC案例(基于纯注解)

F:\spring\day02_eesy_04account_annoioc_withoutxmlAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import org.apache.commons.dbutils.QueryRunner;import org.apache.commons.dbutils.han

2020-06-23 16:45:55 159

原创 简单的IOC案例(基于注解加xml)

F:\spring\day02_eesy_03account_annoiocAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import org.apache.commons.dbutils.QueryRunner;import org.apache.commons.dbutils.handlers.BeanH

2020-06-22 23:09:53 114

原创 简单的IOC案例(基于XML)

F:\spring\day02_eesy_02account_xmliocAccountDaoImpl.javapackage com.itheima.dao.impl;import com.itheima.dao.IAccountDao;import com.itheima.domain.Account;import org.apache.commons.dbutils.QueryRunner;import org.apache.commons.dbutils.handlers.BeanHa

2020-06-22 22:53:57 105

原创 spring对bean的管理细节和依赖注入(基于注解和xml)

F:\spring\day02_eesy_01anno_iocAccountServiceImpl.javapackage com.itheima.service.impl;import com.itheima.dao.IAccountDao;import com.itheima.dao.impl.AccountDaoImpl;//import com.itheima.factory.BeanFactory;import com.itheima.service.IAccountService;

2020-06-22 21:12:00 186

原创 spring中的依赖注入(基于xml)

F:\spring\day01_eesy_05DI<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/sche

2020-06-22 16:54:13 120

原创 spring对bean的管理细节(基于xml文件)

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://ww

2020-06-22 16:38:38 94

原创 spring的Ioc核心容器 ApplicationContext和BeanFactory的区别

package com.itheima.ui;import com.itheima.dao.IAccountDao;//import com.itheima.factory.BeanFactory;import com.itheima.service.IAccountService;import com.itheima.service.impl.AccountServiceImpl;import javafx.application.Application;import org.springfr

2020-06-22 16:30:14 164

原创 自己写一个创建Bean对象的工厂(BeanFactory)

package com.itheima.factory;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.Enumeration;import java.util.HashMap;import java.util.Map;import java.util.Properties;/**一个创建Bean对象的工厂Bean:在计算机英语中

2020-06-22 15:23:44 451

原创 程序的耦合

F:\spring\day01_eesy_01jdbcpackage com.itheima.jdbc;import java.sql.*;/**程序的耦合 耦合:程序间的依赖关系 包括: 类之间的依赖 方法间的依赖 解耦:降低程序间的依赖关系 实际开发中: 应该做到,编译期不依赖,运行时才依赖 解耦的思路: 第一步,使用放射来创建对象,而避免使用new关键字

2020-06-22 14:48:47 95

转载 UVa253 骰子涂色(枚举)

#include <stdio.h>#include <string.h>char s[15], s1[7], s2[7], s3[7];int flag;int d[7][7] = { {0,1,2,3,4,5},{1,5,2,3,0,4},{2,1,5,0,4,3}, {3,1,0,5,4,2},{4,0,2,3,5,1},{5,4,2,3,1,0} };in...

2019-08-02 23:10:13 149

转载 Uva 201 正方形

#include <iostream>#include <cstring> using namespace std; int main(){ ios::sync_with_stdio(false); int v[11][11],h[11][11]; //分别存竖直线和水平线 int m,n,k=0; while(k++,cin>>n>&...

2019-08-02 22:29:38 122

原创 例题4-1 古老的密码 (排序)

//.c#include <stdio.h>#include <stdlib.h>#include <string.h>#define maxn 100 + 10 int cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;} int main(){ ...

2019-08-02 16:49:27 323

转载 习题3-11 换抵挡装置 UVa1588

理解提议后很简单,从头开始找,第一个匹配嵌合的就是最短的了。#include<iostream>#include<cstring>using namespace std;int main(){ char s[105], t[105]; int len1, len2, len; while(cin>>s>>t) ...

2019-07-15 13:52:42 158

原创 习题3-10盒子 UVa1587

对重载运算符的应用题目:https://vjudge.net/problem/UVA-1587#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#include <queue>#in...

2019-07-14 16:45:21 128

原创 习题3-8 循环小数 UVa202

Sample Input76 255 431 397Sample Output76/25 = 3.04(0)1 = number of digits in repeating cycle5/43 = 0.(116279069767441860465)21 = number of digits in repeating cycle1/397 = 0.(002518891687657...

2019-07-13 22:15:45 108

原创 习题3-9 子序列 UVa10340

两个字符串s和t,从t中删除0或多个字符能得到s吗?水题#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char s[100],t[100]; memset(s,0,sizeof(s)); memset(t,0,sizeof(t)); ...

2019-07-13 22:01:00 75

转载 习题3-7 DNA序列 UVa1368

个人觉得难点在于如果有多解,按照字典序最小的解。因为直接算,是不会得出多解的,一般直接得出最优解,那么哪里找来多个解去求最优解。#include<stdio.h>#include<string.h>#define maxn 1000+10#define maxm 50+10#define maxc 150char s[maxm][maxn];char ans...

2019-07-13 16:41:36 120

转载 习题3-6 纵横字谜的答案 UVa232

题意:输入一个r行c列的网格,黑格用*号表示,每个白格都填有一个字母。如果一个白格的左边相邻位置或者上边相邻位置没有白格(可能是黑格,也可能出了网格边界),则称这个白格是一个起始格。首先把所有起始格从左到右,从上到下顺序编号1,2,3,。。。。要求找出所有横向单词。这些单词必须从一个起始格开始,向右延伸到一个黑格的左边或者整个网格的最右边。最后找出所有的竖向单词。想法:找出每个起点的位置,并标志...

2019-07-13 16:13:01 149

转载 习题3-5 谜题 UVa227

给定一个5*5的字母矩阵,按照给定的指令,移动字母,成功输出最后指令即可,否则输出This puzzle has no final configuration.#include<iostream>#include<string>#include<cstdio>#include<cstring>using namespace std; c...

2019-07-13 14:23:15 119

原创 习题3-4 周期串 UVa445

题意:如果一个字符串可以由长度为k的字符串重复得到,则称该串以k为周期。输入一个长度不超过80的字符串,输出其最小周期。想法:一开始想复杂了,其实不难,从1开始到字符串的长度,遍历每个周期,如果符合,则跳出。#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ ...

2019-07-13 14:03:38 200

原创 习题3-3 数数字 UVa1225

把前n(n<10000)个整数顺次写在一起:123456789101112…数一数0~9各出现多少次(输出10个整数,分别是0,1,…,9出现的次数)。运用sprintf(str,"%d",num);将数字以字符形式存入字符串数组,这题即可轻松解决。#include <stdio.h>#include <stdlib.h>#include <string...

2019-07-13 13:39:58 146

原创 习题3-2 分子量 UVa1586

计算分子式的分子量,其中原子量C,H,O,N,分别为12.01,1.008,16.00,14.01例如C6H5OH,一开始想得太简单了,其实要稍微复杂点,数字不一定是个位数。#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ int i,j; doub...

2019-07-13 13:13:24 170

原创 习题3-1 得分 Uva1585

给一个O和X的串,O的得分为目前连续出现的O的个数,

2019-07-13 13:06:58 203

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除