@CyanCoding/

AlarmedComfortableLearning

Java

No description

fork
loading
Files
  • Main.java

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.5892278273022156","path":"Main.java","file":{"path":"Main.java","content":{"asEncoding":{"base64":"aW1wb3J0IGphdmEudXRpbC5jb25jdXJyZW50LlRpbWVVbml0OwoKY2xhc3MgTWFpbiB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgICAgIC8vIFRocmVhZCBydW5zIGFsb25nc2lkZSBwcm9ncmFtIHdpdGhvdXQgZnJlZXppbmcKICAgICAgICAgICAgU3RyaW5nW10gcmV0cmlldmFsQXJhcnkgPSBuZXcgU3RyaW5nWzIwXTsKICAgICAgICAJVGhyZWFkIHRocmVhZCA9IG5ldyBUaHJlYWQobmV3IFJ1bm5hYmxlKCkgewoJCSAgICAgICAgcHVibGljIHZvaWQgcnVuKCkgewogICAgICAgICAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcmV0cmlldmFsQXJhcnkubGVuZ3RoOyBpKyspIHsgLy8gUnVuIGZvciB0aGUgc2FtZSBjb3VudCBhcyB5b3UgaGF2ZSBpdGVtcyBpbiB5b3VyIGFycmF5CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKCQkJCQkJVGltZVVuaXQuU0VDT05EUy5zbGVlcCg1KTsgLy8gU2xlZXBzIHRoZSB0aHJlYWQgZm9yIGZpdmUgc2Vjb25kcwoJCQkJCX0gY2F0Y2ggKEludGVycnVwdGVkRXhjZXB0aW9uIGUpIHsKCQkJCQkJZS5wcmludFN0YWNrVHJhY2UoKTsKCQkJCQl9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHJpZXZhbEFyYXJ5W2ldID0gSW50ZWdlci50b1N0cmluZyhpKTsgLy8gQWRkIHRoZSBpbnRlZ2VyIHJ1biBjb3VudCB0byB0aGUgYXJyYXkKICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGkpOyAvLyBTaG93IHByb2dyZXNzCiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KTsKICAgICAgICAgICAgdGhyZWFkLnN0YXJ0KCk7CgogICAgfQp9"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.concurrent.TimeUnit;

class Main {
    public static void main(String[] args) {
            // Thread runs alongside program without freezing
            String[] retrievalArary = new String[20];
        	Thread thread = new Thread(new Runnable() {
		        public void run() {
                    for (int i = 0; i < retrievalArary.length; i++) { // Run for the same count as you have items in your array
                    try {
						TimeUnit.SECONDS.sleep(5); // Sleeps the thread for five seconds
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
                        retrievalArary[i] = Integer.toString(i); // Add the integer run count to the array
                        System.out.println(i); // Show progress
                    }
                    
                }
            });
            thread.start();

    }
}