cat_mucius: (Default)
[personal profile] cat_mucius
Вот какой бы вывод вы ожидали увидеть, запустив такую простенькую java-програмку на винде?
public static void main(String[] args)
{
    long first;
    long next;
				
    first = System.currentTimeMillis();
    while (true)
    {
        next = System.currentTimeMillis();
        if (first != next)
            break;
    }
				
    System.out.println("Difference: " + (next - first));
}


А такую?
public static void main(String[] args)
{
    long first;
    long next;
		
    Thread t = new Thread()
    {
        public void run()
        {
            try
            {
                Thread.sleep(Integer.MAX_VALUE);
            } catch (InterruptedException e) {}
        }
    };
    t.start();
		
    first = System.currentTimeMillis();
    while (true)
    {
        next = System.currentTimeMillis();
        if (first != next)
            break;
    }
				
    System.out.println("Difference: " + (next - first));
    t.interrupt();
}


Жизнь, натурально, прекрасна и удивительна.
You may post here only if cat_mucius has given you access; posting by non-Access List accounts has been disabled.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

cat_mucius: (Default)
cat_mucius

June 2025

S M T W T F S
1 234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 18th, 2025 08:14 am
Powered by Dreamwidth Studios