简体   繁体   English

使用System.out打印输出作为另一个程序(Java)的输入

[英]Use System.out printout as input for another program (Java)

A simple scenario here, 这里有一个简单的场景,

I have a thread (let's call it A ) that writes to terminal indefinitely(using System.out ) I need to somehow retrieve those information from another Thread (let's call it B ). 我有一个线程(使用A. )可以无限期地写到终端(使用System.out ),我需要以某种方式从另一个线程(称为B )中检索那些信息。 The problem is that A and B cannot communicate in any other way. 问题是AB无法以任何其他方式进行通信。

So is there a way that B can retrieve those information from terminal? 那么, B可以从终端检索那些信息吗?

Note: This is a prototype I'm designing. 注意:这是我正在设计的原型。 thread A can be any other process and not necessarily written in Java, it just runs on a terminal indefinately 线程A可以是任何其他进程,不一定是用Java编写的,它只能在终端上不确定地运行

You could just create a class that can hold all the required informations for the threads. 您可以只创建一个类,该类可以包含线程的所有必需信息。 Or use a File and just place everything in there (like a "simulated console"), but that's rather ugly than anything else if you ask me.. 或使用文件,然后将所有内容放在其中(例如“模拟控制台”),但是如果您问我,那比其他任何东西都难看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM