Jump to content



Photo

Start a new thread in a new command prompt

java thread cmd

  • Please log in to reply
5 replies to this topic

#1 thatguyandrew1992

thatguyandrew1992

    Neowinian Senior

  • Tech Issues Solved: 3
  • Joined: 22-January 09

Posted 19 June 2013 - 05:26

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 




#2 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 19 June 2013 - 05:43

I'm guessing something along these lines would help:

 

http://stackoverflow...l/343007#343007



#3 Andre S.

Andre S.

    Asik

  • Tech Issues Solved: 10
  • Joined: 26-October 05

Posted 19 June 2013 - 17:02

*snip* (didn't read the question properly, sorry)



#4 kjordan2001

kjordan2001

    Mystery Solver

  • Joined: 27-May 02

Posted 19 June 2013 - 23:32

I'm guessing something along these lines would help:

 

http://stackoverflow...l/343007#343007

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.



#5 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 20 June 2013 - 00:47

^ 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..



#6 OP thatguyandrew1992

thatguyandrew1992

    Neowinian Senior

  • Tech Issues Solved: 3
  • Joined: 22-January 09

Posted 20 June 2013 - 06:40

I'm guessing something along these lines would help:

 

http://stackoverflow...l/343007#343007

 

Thanks! I will look into this!





Click here to login or here to register to remove this ad, it's free!