HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavaMinor

Spawning threads to process data

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
threadsspawningdataprocess

Problem

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 retrieve 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?

Solution

I have no problem the ternary operator.

But it is hard to tell that the result is what the comments is saying. Without having a context on what time is (which is a bad variable name) it is hard to understand the result of the function.

time: Bad variable name. Time of what?

Context

StackExchange Code Review Q#562, answer score: 6

Revisions (0)

No revisions yet.