Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Java 8 MacOs and Performance  RSS feed

Ranch Hand
Posts: 233
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No idea which forum this goes into if indeed it's anything to do with Java at all.

I have some serious database work being carried out by a Java Swing application and I've noticed by monitoring the progress of the database updates that it works a lot faster if the Java Swing application is in the foreground and has focus.

It's probably just how MacOS works, but it has made me wonder if there is anything that can be done within Java to request that the operating system gives Java a higher priority. Failing that I suppose I will just have to keep the program in the foreground.
Posts: 6363
BSD Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David!

1. In terminal execute "top" instruction and find PID (process id) of your running task.
2. Execute instruction "ps -lp pid" (replace pid with the number identified from the step 1).

Now, after executing second instruction, you'll see NI attribute in a given table, it is a niceness level, ranging from -20 to 19. Default is 0, so I guess that is what is going to be for your program set.
The lower niceness level, the higher CPU priority to your program will be given.

3. To change the priority you need to execute instruction "sudo renice -n level -p pid" (by replacing level with the number in a range of -20 and 19 and pid with process id of your running program).

Note: entering this instruction, you'll be asked to enter your superuser password, so do.

Read more about the commands renice and nice by executing "man renice" and "man nice" in the terminal (note: quotes not needed).
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!