Prozesse und Prioritäten

Status
Nicht offen für weitere Antworten.

HilfeSucher

Mitglied
Hallo ihr Experten, ich hab ein Performance Problem:
und zwar öffnet mein Programm einen exteren Prozess, der furchtbar lange rechnet. Um dennoch vernünftig am Computer arbeiten zu können, habe ich bisher den Prozess per Hand im Taskmanager auf "niedrige Priorität" gestellt. Kann ich das auch irgendwie aus meinem Programm heraus machen?
Hab bisher die Option nur unter Threads gefunden, aber die macht nicht das was ich mir vorstelle.

Thx 4 Help
 

Ralph-Uwe

Bekanntes Mitglied
Hi HilfeSucher,

Ich bin zwar auch kein Fachmann was die Performance angeht, aber
lass doch die externe Anwendung im eigenen Thread laufen und setze für den die Prioität runter.

Ralph
 
T

tuxedo

Gast
Doch, das geht. Aber eben nicht mit Java. Wenn du deine Prozesse mit "start" aufrufst, dann schau dir das mal an:

C:\Documents and Settings\achr>start /?
Starts a separate window to run a specified program or command.

START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/WAIT] [/B] [command/program]
[parameters]

"title" Title to display in window title bar.
path Starting directory
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized
MAX Start window maximized
SEPARATE Start 16-bit Windows program in separate memory space
SHARED Start 16-bit Windows program in shared memory space
LOW Start application in the IDLE priority class
NORMAL Start application in the NORMAL priority class
HIGH Start application in the HIGH priority class
REALTIME Start application in the REALTIME priority class
ABOVENORMAL Start application in the ABOVENORMAL priority class
BELOWNORMAL Start application in the BELOWNORMAL priority class
WAIT Start application and wait for it to terminate
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.

If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed application
or a console application.

parameters These are the parameters passed to the command/program


If Command Extensions are enabled, external command invocation
through the command line or the START command changes as follows:

non-executable files may be invoked through their file association just
by typing the name of the file as a command. (e.g. WORD.DOC would
launch the application associated with the .DOC file extension).
See the ASSOC and FTYPE commands for how to create these
associations from within a command script.

When executing an application that is a 32-bit GUI application, CMD.EXE
does not wait for the application to terminate before returning to
the command prompt. This new behavior does NOT occur if executing
within a command script.

When executing a command line whose first token is the string "CMD "
without an extension or path qualifier, then "CMD" is replaced with
the value of the COMSPEC variable. This prevents picking up CMD.EXE
from the current directory.

When executing a command line whose first token does NOT contain an
extension, then CMD.EXE uses the value of the PATHEXT
environment variable to determine which extensions to look for
and in what order. The default value for the PATHEXT variable
is:

.COM;.EXE;.BAT;.CMD

Press any key to continue . . .
 

HilfeSucher

Mitglied
mmm werd nicht ganz schlau daraus...
Ich starte meine Prozesse mit dem ProcessBuilder

Code:
ProcessBuilder scip = new ProcessBuilder(new String[] {
"cmd","/c","Pfad\\programm.exe"});

ist das das selbe wie über "start" aufrufen? ???:L - falls nicht wie geht das mit start?
Ich könnte auch damit leben, wenn meine gesammtes Programm eine niedrigere Priorität hat, wenn das einfacher zu implementieren ist.
 

HilfeSucher

Mitglied
OK es klappt soweit das das externe Programm mit niedriger Priorität läuft.
Allerdings bekomme ich jetzt den Inputstream nicht mehr zu fassen...und mein p.waitFor() wird auch einfach ignoriert.
Mein Code sieht so aus:

Code:
				Process p = Runtime.getRuntime().exec(builder.toString());
				
				InputStream is =p.getInputStream();
				BufferedReader br = new BufferedReader(new
			        		InputStreamReader(is));
				
				while(p.exitValue()!=0){
					System.out.println(br.readLine());
				}
				
				p.waitFor();
				
				System.out.print("Fertig");

p.exitValue wirft mir ein "der Prozess ist noch nicht beendet" um den Kopf und beendet mein "Try".
Ein einfaches
Code:
while(br.readLine()!=null)
wird auch einfach übergangen. Kann es daran liegen, das mein Programm ein Fenster öffnet und dort den Output reinschreibt?

Danke für eure Zeit
 
T

tuxedo

Gast
Ja, das wirds sein. Bin mir nicht sicher ob du an die Prozessausgabe noch drankommst wenn du's mit "start" gestartet hast.

- Alex
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
Kirby.exe Prozesse Automatisieren Allgemeine Java-Themen 10
B Erste Schritte Script für Webseiten-Prozesse entwickeln Allgemeine Java-Themen 9
B JAVA Prozesse in einer eigenen Anwendung laufen lassen Allgemeine Java-Themen 9
B Threads Barrier mit wait()/notify() aber nicht alle Prozesse terminieren Allgemeine Java-Themen 2
A boolean und prozesse Allgemeine Java-Themen 2
T Synchronisation von Listen bei Zugriffen durch mehrere Prozesse Allgemeine Java-Themen 15
J Prozesse + Arbeitsspeicher beobachten Allgemeine Java-Themen 12
E Alle unter Prozesse der beim schließen mit schließen Allgemeine Java-Themen 3
G Threads und Prozesse Allgemeine Java-Themen 3
O Windows-Prozesse/ Tasks überwachen Allgemeine Java-Themen 3
thE_29 Java Prozesse der eigenen JVM Allgemeine Java-Themen 12
G Prozesse überwachen und neustarten Allgemeine Java-Themen 3
T java Pendant zu "ps" (Auflisten laufender Prozesse Allgemeine Java-Themen 4
H Externe Prozesse und Inputstreams - ausgabe in JTextArea Allgemeine Java-Themen 3
N Unter Mac Os X alle laufenden Prozesse ausgeben Allgemeine Java-Themen 3
J Windows-Prozesse beobachten Allgemeine Java-Themen 24
S Commandline / Prozesse Problem Allgemeine Java-Themen 4
B Prozesse einschränken Allgemeine Java-Themen 11
L Prozesse parsen ? Allgemeine Java-Themen 2
M Zugriff auf andere Prozesse Allgemeine Java-Themen 3
T Concurrent Modification Exception vermeiden mit Prioritäten Allgemeine Java-Themen 4

Ähnliche Java Themen


Oben