tanyang93
young-tan
采纳率0%
2018-06-19 07:47 阅读 1.2k

SimpleDataFormat.format 被Locked导致出现ANR

5

如下是代码:
public static synchronized void d(String TAG, String content) {
Log.d(TAG, "robot : " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()) + content);
}

如下是traces部分日志。

"main" prio=5 tid=1 WaitingForDebuggerSend
| group="main" sCount=1 dsCount=0 obj=0x73a3f4a0 self=0xee285400
| sysTid=1375 nice=-10 cgrp=default sched=0/0 handle=0xf1036534
| state=S schedstat=( 1864681993184 49642950547 342220 ) utm=181892 stm=4575 core=5 HZ=100
| stack=0xff664000-0xff666000 stackSize=8MB
| held mutexes=
kernel: switch_to+0x98/0xa4
kernel: futex_wait_queue_me+0xd8/0x144
kernel: futex_wait+0xec/0x200
kernel: do_futex+0xdc/0x4ec
kernel: compat_SyS_futex+0xdc/0x168
kernel: el0_svc_naked+0x24/0x28
native: #00 pc 00017404 /system/lib/libc.so (syscall+28)
native: #01 pc 000b5a57 /system/lib/libart.so (_ZN3art5Mutex13ExclusiveLockEPNS_6ThreadE+210)
native: #02 pc 00247595 /system/lib/libart.so (_ZN3art4JDWP9JdwpState19SendBufferedRequestEjRKNSt3
16vectorI5iovecNS2_9allocatorIS4_EEEE+116)
native: #03 pc 002428bd /system/lib/libart.so (_ZN3art4JDWP9JdwpState13DdmSendChunkVEjPK5ioveci+620)
native: #04 pc 0010d52f /system/lib/libart.so (_ZN3art3Dbg15DdmSendHeapInfoENS0_8HpifWhenE+1262)
native: #05 pc 0010cb5b /system/lib/libart.so (_ZN3art3Dbg11GcDidFinishEv+462)
native: #06 pc 001936d5 /system/lib/libart.so (_ZN3art2gc4Heap22CollectGarbageInternalENS0_9collector6GcTypeENS0_7GcCauseEb+2548)
native: #07 pc 001968cf /system/lib/libart.so (_ZN3art2gc4Heap46PushOnThreadLocalAllocationStackWithInternalGCEPNS_6ThreadEPPNS_6mirror6ObjectE+46)
native: #08 pc 0039c2f1 /system/lib/libart.so (artAllocObjectFromCodeRosAlloc+352)
native: #09 pc 000adfd9 /system/lib/libart.so (art_quick_alloc_object_rosalloc+136)
native: #10 pc 002f0d03 /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_icu_impl_ICUResourceBundleImpl_createBundleObject__Ljava_lang_String_2ILjava_util_HashMap_2Landroid_icu_util_UResourceBundle_2+334)
at android.icu.impl.ICUResourceBundleImpl.createBundleObject(ICUResourceBundleImpl.java:48)
at android.icu.impl.ICUResourceBundleImpl$ResourceTable.handleGet(ICUResourceBundleImpl.java:233)
at android.icu.util.UResourceBundle.findTopLevel(UResourceBundle.java:688)
at android.icu.impl.ICUResourceBundle.findTopLevel(ICUResourceBundle.java:419)
at android.icu.impl.ICUCurrencyDisplayInfoProvider$ICUCurrencyDisplayInfo.(ICUCurrencyDisplayInfoProvider.java:60)
at android.icu.impl.ICUCurrencyDisplayInfoProvider.getInstance(ICUCurrencyDisplayInfoProvider.java:41)
at android.icu.text.CurrencyDisplayNames.getInstance(CurrencyDisplayNames.java:36)
at android.icu.util.Currency.getName(Currency.java:521)
at android.icu.util.Currency.getSymbol(Currency.java:473)
at android.icu.util.Currency.getSymbol(Currency.java:463)
at java.util.Currency.getSymbol(Currency.java:213)
at java.text.DecimalFormatSymbols.setInternationalCurrencySymbol(DecimalFormatSymbols.java:396)
at java.text.DecimalFormatSymbols.fromIcuInstance(DecimalFormatSymbols.java:744)
at java.text.DecimalFormat.getDecimalFormatSymbols(DecimalFormat.java:831)
at java.text.SimpleDateFormat.zeroPaddingNumber(SimpleDateFormat.java:1334)
at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1110)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:959)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:929)
at java.text.DateFormat.format(DateFormat.java:337)
at com.flyingwings.cn.base.util.RobotDebugLog.d(RobotDebugLog.java:71)

  • locked (a java.lang.Class) at com.flyingwings.cn.robot.service.robotinforservice.RobotStatusService$RobotStatusHandler.handleMessage(RobotStatusService.java:54) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke!(Native method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • qq_41605874 qq_41605874 2018-06-19 08:03

    你转完以后是Date类型了,步可能会是你想要的格式额。 也不能实现。
    你从jsp里传来的是什么什么用样子,另外你转成date存到数据库里就可以了,查询的时候在转成你要的格式,如果你想直接存,那就不要用date存到数据库里。

    点赞 评论 复制链接分享

相关推荐