Code example for TimeUnit

Methods: convert

0
            boolean bVal = true;
            try 
            { 
                if (!done.get())
                { 
                    timeout = TimeUnit.MILLISECONDS.convert(timeout, tu);
                    long overall_timeout = timeout - (System.currentTimeMillis() - startTime);
                    bVal = overall_timeout > 0 && condition.await(overall_timeout, TimeUnit.MILLISECONDS);
                } 
            } 
            catch (InterruptedException ex)
            { 
                throw new AssertionError(ex);
            } 
             
            if (!bVal && !done.get())
            {                                            
                throw new TimeoutException("Operation timed out.");
            } 
        } 
Experience pair programming with AI  Get Codota for Java