为什么System.err.println停留在写入状态?

时间:2018-06-25 08:27:45

标签: java android monkey

有人知道为什么System.err.println停留在写入状态吗?问题在猴子测试期间发生,请检查代码,该代码卡在System.err.println(s)上;这里是调用堆栈:

"main" prio=10 tid=1 Native
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x12c01e18 self=0x793e45ea00
  | sysTid=14489 nice=-8 cgrp=default sched=0/0 handle=0x79c34989a8
  | state=S schedstat=( 893730957 58891353 263 ) utm=66 stm=23 core=1 HZ=100
  | stack=0x7ff175a000-0x7ff175c000 stackSize=8MB
  | held mutexes=
  kernel: __switch_to+0xa4/0xd8
  kernel: pipe_wait+0x6c/0xb8
  kernel: pipe_write+0x1dc/0x444
  kernel: new_sync_write+0xd8/0x124
  kernel: vfs_write+0x15c/0x1d0
  kernel: SyS_write+0x60/0xc0
  kernel: __sys_trace+0x4c/0x4c
  native: #00 pc 000000000007afb4  /system/lib64/libc.so (write+4)
  native: #01 pc 0000000000032e14  /system/lib64/libjavacore.so (???)
  native: #02 pc 0000000000237194  /system/framework/arm64/boot-core-libart.oat (Java_libcore_io_Linux_writeBytes__Ljava_io_FileDescriptor_2Ljava_lang_Object_2II+196)
  at libcore.io.Linux.writeBytes(Native method)
  at libcore.io.Linux.write(Linux.java:288)
  at libcore.io.BlockGuardOs.write(BlockGuardOs.java:345)
  at libcore.io.IoBridge.write(IoBridge.java:553)
  at java.io.FileOutputStream.write(FileOutputStream.java:326)
  at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
  at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
  - locked <0x0ee2596f> (a java.io.BufferedOutputStream)
  at java.io.PrintStream.write(PrintStream.java:505)
  - locked <0x087a167c> (a java.io.PrintStream)
  at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
  at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
  at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
  - locked <0x0ebd8b05> (a java.io.OutputStreamWriter)
  at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
  at java.io.PrintStream.write(PrintStream.java:554)
  - locked <0x087a167c> (a java.io.PrintStream)
  at java.io.PrintStream.print(PrintStream.java:698)
  at java.io.PrintStream.println(PrintStream.java:835)
  - locked <0x087a167c> (a java.io.PrintStream)
  at com.android.commands.monkey.Logger$2.println(Logger.java:37)
  at com.android.commands.monkey.Monkey.commandLineReport(Monkey.java:510)

1 个答案:

答案 0 :(得分:0)

读取System.err的内容很可能没有使用数据。缓冲区填满后,程序将等待,直到缓冲区中有空间可以写入更多内容。