• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to run multiple processes at once, while still able to type commands to system.in

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an assignment that involves making a command provider through system.out and system.in. Im kinda stuck because my application needs to be able to open other application (notepad, cmd, etc.) and I have accomplished that but the application needs to be able to run multiple processes at once, thats where I get stuck because when I run a application like notepad my command provider which I feed commands in order to run applications, stops responding.

Basicly here�s how I do it:


So when I type: run notepad. A notepad runs with empty txt file, but if I type: run notepad c:\myDocument.txt it opens notepad and loads the given text file.

How do I run multiple instances of f.ex notepad? I�ve tried using threads but it ain�t quite working.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us your threading code that didn't work, please?
 
Unnar Björnsson
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here it goes:


I created an instance of Program every time the executeRun command is called.

 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Don't call the run method directly.

Call start() instead and it will work.

When you call run() directly it acts just like any other function. What you really need is to create a new thread and run it, and you use the start() method for that.
 
Unnar Björnsson
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out, I was referring to the array program that wasn�t in the run() methods scope so I got NullPointerException. Thanks for the help though.
 
There's a city wid manhunt for this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic