我正在打开一个PowerShell实例并通过系统发送命令。,我想将输出收集到一个队列中,这样我就可以在不干扰输入命令的情况下打印结果。但是,主线程上的队列没有填充,在主线程上休眠只能稍微修复这个问题。我想问题是没有同步队列,但我不确定如何。
package PWST;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class PWST {
public static void main(String[] args) {
try {
Scanner in = new Scanner(System.in);
System.out.print("