• 0

Start a new thread in a new command prompt


Question

Hey all,

I was wondering if its possible in Java to start a new thread and have all that code print out in a new command prompt.

 

eg

main()
   print Hi
   new thread
      while(1>0)
         print 1
   while(1>0)
      print 0

original commands prompt would display: Hi 0000000000

second command prompt would display: 11111111111 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

I'd say something like that would be the way to go since creating a new "command prompt" (cmd.exe, xterm, whatever) would be trickier to pass that output to.  You could probably end up doing it though by starting a new instance of the command line terminal using Runtime's exec method  and running the command "more" in that command line (both Windows and Linux have a version of this) and then sending output to the InputStream for the command line Process.  This would make it display in the "more" program's buffer instead of getting interpreted by the command line program.

Link to comment
Share on other sites

  • 0

^ That's exactly what I thought.

 

The only neat way to do it out side of this is to create multiple programs, however that means you need to write a way to communicate between them..

Link to comment
Share on other sites

This topic is now closed to further replies.