Tag: 命名管道

Java中命名管道的并发读/写(在Windows上)

我正在尝试使用命名管道在Windows上提供C#应用程序和Java应用程序之间的通信,该管道使用v01ver在此问题中描述的方法: 如何从Java打开Windows命名管道? 我在Java方面遇到了一个问题,因为我有一个读者线程经常在管道上等待输入,当我尝试从我的主线程写入管道时,它会永远被卡住。 final RandomAccessFile pipe; try { pipe = new RandomAccessFile(“\\\\.\\pipe\\mypipe”, “rw”); } catch (FileNotFoundException ex) { ex.printStackTrace(); return; } Thread readerThread = new Thread(new Runnable() { @Override public void run() { String line = null; try { while (null != (line = pipe.readLine())) { System.out.println(line); } } catch (IOException ex) { ex.printStackTrace(); } […]