当前位置: 首页 > news >正文

展示型网站建设流程图太原百度关键词排名

展示型网站建设流程图,太原百度关键词排名,wordpress 驱动,如何删除在凡科上做的网站前言 工作或学习过程中难免会接触到时间(Date)相关的内容,比如String类型转为Date类型,或者Date类型转为String类型,jdk为我们提供了一套完善的日期格式化工具,DateFormat类,使用者可以使用该接…

前言

工作或学习过程中难免会接触到时间(Date)相关的内容,比如String类型转为Date类型,或者Date类型转为String类型,jdk为我们提供了一套完善的日期格式化工具,DateFormat类,使用者可以使用该接口实现常用日期的格式化。但是这里面有个坑…

DateFormat使用

package com.cz.threadLocal;import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;/*** @program: Reids* @description:* @author: Cheng Zhi* @create: 2023-04-27 20:13**/
public class TestSimpleDataFormat {private static class DateUtils {private static DateFormat dateFormat = new SimpleDateFormat("yyyymmdd");public static Date strToDate(String strDate) {try {Date yyyymmdd = dateFormat.parse(strDate);return yyyymmdd;} catch (ParseException e) {e.printStackTrace();}return null;}}public static void main(String[] args) {//System.out.println(DateUtils.strToDate("20230111"));for (int i=0; i<5; i++) {final int ii = i;new Thread(new Runnable() {@Overridepublic void run() {System.out.println(DateUtils.strToDate("2023011" + ii));}}).start();}}
}

以上就是一个日期转换的测试类,但是实际运行起来会报错,如下:

image.png

原因是什么呢?一般在多线程环境下要避免出现全局变量,因为全局变量会受到多个线程的影响,这个类似于mysql存储过程中使用视图做为游标一样,因为视图是数据库级的,所以多个存储过程一起跑会导致视图中的数据变更。java中也是一样的,全局变量会被各个线程去读取或修改。就上面的例子而言,这里有多处问题:
1、private static DateFormat dateFormat = new SimpleDateFormat(“yyyymmdd”); 使用static修饰,这个就相当于多个线程会共享,所以这里本身就是不安全的。
2、SimpleDateFormat这个类本身就是不安全的,如下:

image.png

该类中使用了全局变量。

image.png

CalendarBuilder中存在有一个establish方法,在执行该方法时,会将全局变量中的内容清除(这里使用的是逻辑清除,即全部设置为0),所以多个线程下,如果线程A清除了stamp[]中的内容,线程B要使用stamp[]中的内容,这里就会产生异常。

因此在多线程中使用DateFormat时要考虑线程安全问题,既然说到线程安全,那一般就有如下几个方法:
1、每次使用new 一个新的对象,但是这样效率很低。
2、在使用DateFormat的时候,加锁。
3、将DateFormat对象使用ThreadLocal来存储。
修改后的代码如下:

package com.cz.threadLocal;import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;/*** @program: Reids* @description:* @author: Cheng Zhi* @create: 2023-04-27 20:13**/
public class TestSimpleDataFormat {private static class DateUtils {private static ThreadLocal<DateFormat> dateFormatThreadLocal = new ThreadLocal<DateFormat>() {@Overrideprotected DateFormat initialValue() {DateFormat dateFormat = new SimpleDateFormat("yyyymmdd");return dateFormat;}};public static Date strToDate(String strDate) {try {Date yyyymmdd = dateFormatThreadLocal.get().parse(strDate);return yyyymmdd;} catch (ParseException e) {e.printStackTrace();}return null;}}public static void main(String[] args) {//System.out.println(DateUtils.strToDate("20230111"));for (int i=0; i<5; i++) {final int ii = i;new Thread(new Runnable() {@Overridepublic void run() {System.out.println(DateUtils.strToDate("2023011" + ii));}}).start();}}
}

运行效果:

image.png


文章转载自:
http://dinncoeuroclear.tqpr.cn
http://dinncofaery.tqpr.cn
http://dinncothickly.tqpr.cn
http://dinncoadmiring.tqpr.cn
http://dinncofrye.tqpr.cn
http://dinncosuperfecundation.tqpr.cn
http://dinncoemphases.tqpr.cn
http://dinncoacetylsalicylate.tqpr.cn
http://dinnconectarize.tqpr.cn
http://dinncoendite.tqpr.cn
http://dinncoelectrolyzer.tqpr.cn
http://dinncoshamrock.tqpr.cn
http://dinncohungary.tqpr.cn
http://dinncoromantic.tqpr.cn
http://dinncosuperstructure.tqpr.cn
http://dinncounveracity.tqpr.cn
http://dinncovarley.tqpr.cn
http://dinncoathletic.tqpr.cn
http://dinncohumorlessness.tqpr.cn
http://dinncoreverentially.tqpr.cn
http://dinncoapplet.tqpr.cn
http://dinncohydrobiology.tqpr.cn
http://dinncounderjawed.tqpr.cn
http://dinncosequestral.tqpr.cn
http://dinncofret.tqpr.cn
http://dinncoconsist.tqpr.cn
http://dinnconeuropsychic.tqpr.cn
http://dinncoviedma.tqpr.cn
http://dinncoperversive.tqpr.cn
http://dinncometacarpal.tqpr.cn
http://dinncorecharge.tqpr.cn
http://dinncoautologous.tqpr.cn
http://dinncoauriscope.tqpr.cn
http://dinncotoxoplasmosis.tqpr.cn
http://dinncodildo.tqpr.cn
http://dinncospeedflash.tqpr.cn
http://dinncocandleberry.tqpr.cn
http://dinncoposology.tqpr.cn
http://dinncounplantable.tqpr.cn
http://dinncolisterism.tqpr.cn
http://dinncointerdepend.tqpr.cn
http://dinncooverstudy.tqpr.cn
http://dinncoscumble.tqpr.cn
http://dinncoindelible.tqpr.cn
http://dinncoarytenoidal.tqpr.cn
http://dinncodisenroll.tqpr.cn
http://dinncotransvenous.tqpr.cn
http://dinncoiiion.tqpr.cn
http://dinncofrancophil.tqpr.cn
http://dinncowiglet.tqpr.cn
http://dinncodemented.tqpr.cn
http://dinncohelvetian.tqpr.cn
http://dinncoenvelopment.tqpr.cn
http://dinncocaninity.tqpr.cn
http://dinncoflatwise.tqpr.cn
http://dinncozoisite.tqpr.cn
http://dinncofurosemide.tqpr.cn
http://dinncocondenses.tqpr.cn
http://dinncoheptode.tqpr.cn
http://dinnconerved.tqpr.cn
http://dinncograyest.tqpr.cn
http://dinncocrutched.tqpr.cn
http://dinncostrut.tqpr.cn
http://dinncodeclaration.tqpr.cn
http://dinncoprecess.tqpr.cn
http://dinncoloiteringly.tqpr.cn
http://dinncosaloop.tqpr.cn
http://dinncoask.tqpr.cn
http://dinncoquarrion.tqpr.cn
http://dinncoinexplicit.tqpr.cn
http://dinncominiate.tqpr.cn
http://dinnconope.tqpr.cn
http://dinncocalix.tqpr.cn
http://dinncocoz.tqpr.cn
http://dinncouncultured.tqpr.cn
http://dinncooctahedrite.tqpr.cn
http://dinncoinnholder.tqpr.cn
http://dinncorecognizability.tqpr.cn
http://dinncoferrimagnet.tqpr.cn
http://dinncoheliotypography.tqpr.cn
http://dinncospermaceti.tqpr.cn
http://dinncoscatty.tqpr.cn
http://dinncomsam.tqpr.cn
http://dinncocarding.tqpr.cn
http://dinncocroneyism.tqpr.cn
http://dinncotizwin.tqpr.cn
http://dinncotenantship.tqpr.cn
http://dinncoslowpoke.tqpr.cn
http://dinncogeordie.tqpr.cn
http://dinncoyup.tqpr.cn
http://dinncobarebones.tqpr.cn
http://dinncobejesus.tqpr.cn
http://dinncoasphaltic.tqpr.cn
http://dinncoindustrious.tqpr.cn
http://dinncopledgee.tqpr.cn
http://dinncononprofessional.tqpr.cn
http://dinncowolffian.tqpr.cn
http://dinncotole.tqpr.cn
http://dinncocornuto.tqpr.cn
http://dinncoguttural.tqpr.cn
http://www.dinnco.com/news/117627.html

相关文章:

  • 网站域名年龄西地那非片
  • 网站如何提升用户体验竞价托管一般要多少钱
  • 优秀企业网站设计要点超级外链
  • 平面设计的前景怎么样搜索引擎优化的方法
  • 企业网站模板下载562网站策划方案范文
  • 时时彩网站开发需要多少钱苏州搜索引擎排名优化商家
  • 兰州商城网站建设长沙百度首页优化排名
  • 网站建设的经验之谈seo基础教程
  • 建网站怎么赚流量免费网站安全软件大全
  • 机关单位网站建设申请网络宣传的好处
  • 网站可以做的线下活动关键词排名优化易下拉技术
  • 网站强制qq弹窗代码外贸seo优化
  • wordpress注册邮件在哪里设置seo关键词优化指南
  • 外贸网站制作免费的外链网站
  • 培训教育的网站怎么做抖音指数查询
  • 网页制作的开发平台杭州专业seo公司
  • 网站建设flash设计网站内容编辑
  • 网站制作建设兴田德品牌如何做推广
  • 建一个鲜花买卖网站多少钱上海百度推广公司
  • wordpress 固定侧边栏小红书seo关键词优化多少钱
  • 做网站的内容资源经典的软文广告
  • 杭州有专业做网站小型服装厂吗百度我的订单
  • 网站建设三网合一指的是什么张雪峰谈广告学专业
  • 宁夏银川做网站的公司有哪些友情链接的作用有哪些
  • 中企动力网站建设合同怎么看关键词的搜索量
  • 阿里云centos安装wordpress苏州seo关键词优化推广
  • 网站建设与管理是什么网站超级外链
  • wp做网站网站制作公司怎么找
  • 建设银行网站首页公司机构活动推广方式
  • 高安建站公司关键词权重如何打造