• Post Reply Bookmark Topic Watch Topic
  • New Topic

Knowing other user processes?  RSS feed

 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I want to write a program so that it only starts execution if there is no other user processes running. Otherwise, it should exit. Is it possibly to do so in Java?

Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No other copies of this same program, or no other processes at all? The first is fairly easy: the first copy just opens a ServerSocket, creates a file, or otherwise grabs control of some resource to let later copies know it exists. The second is not possible in pure Java; you'd have to do some platform-specific work, either using native methods or executing some external program. Furthermore, you'd have to define what "user processes" were, as any modern computer has dozens of processes running on it even when it first starts up. How do you distinguish "user processes" from "system processes?"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!