Sign in to follow this  
Followers 0

java Start a new thread in a new command prompt


6 posts in this topic

Posted

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 

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Posted

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.

Share this post


Link to post
Share on other sites

Posted

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.