Console.readLine() and Console.printf() are mutually blocking

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 23
    • Component/s: core-libs
    • None

      Following example demonstrates how IO::readln and IO::println are mutually blocking and how IO.println behaved differently than System.out.println in multithreaded code.


      ```
      static void doSomething() {
          try {
             Thread.sleep(1000);
         } catch (InterruptedException ignore) {}
      }
       
      void main() {
         Thread.ofVirtual().start(() -> {
              while (true) {
                  doSomething();
                 System.out.println("I do something until you press Enter");
             }
         });
         Thread.ofVirtual().start(() -> {
              while (true) {
                  doSomething();
                  println("I'm blocked until you press Enter");
             }
         });
          readln("");
      }
      ```

            Assignee:
            Naoto Sato
            Reporter:
            Adam Sotona
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: