I have a class that spawns threads to process data. I am working on instrumentation code. When the process is started, time = System.currentTimeMillis(); When it completes, time = System.currentTimeMillis() - time; I have a method to retrive this time:/** * Get the time taken for process to complete *  * @return Time this process has run if running; time it took to complete if not */public long getRunTime() {   return processRunning? System.currentTimeMillis() - time : time;}Is this a clear use of the ternary operator? Is my javadoc comment clear?
Spawning threads to process data
java;datetime
Since the method has a return value even if the code is not finished processing the first line of your javadoc ought not read Get the time taken for process to complete but perhaps rather Get the current or total processing time or something of that nature? I also agree with Bert F's comment, but if there were clear comments explaining the behavior and you don't intend on exposing start and end times individually then there's no reason to waste an extra variable; you can either keep the code as it is and add comments or optionally get rid of the boolean processRunning and instead use your completedTime/runTime variable to establish the fact that it's still running. All minor gripes, all in all.