Understanding program, process and threads in shiny application

hi all,

I wanted to understand little bit of backend mechanism that happens when shiny applications are run.
This is a simple application (i have mentioned the steps of execution)

So what I Understand is,

  1. This is program containing 7 steps of execution
  2. This program when launched , a process is created where this application runs
  3. Process thus created has single thread which performs the execution

Is my understanding correct?
Is this how a program is executed. If so, how can we make this program work on multi-thread ?

ui <- fluidPage(
  numericInput("x", "X", value = 5), ## Step 1
  textOutput("txt"), ## Step 2
  actionButton("button", "Submit") ## Step 3
)

server <- function(input, output, session) {

  asd <- data.frame(Cat1 = c("A", "A", "B", "B"), Cat2 = c("x","y", "x1", "y1")) ## Step 4
  # server_1(input, output, session , y1)

  y1 <- reactiveValues(a = 0) ## Step 5
  function1 <- function(){
    y1$a = 2 * input$x
  }

  observeEvent(input$button,{ ## Step 6
    function1()
  })

  output$txt <- renderText({ ## Step 7
    y1$a
  })
}

shinyApp(ui, server)

If you mean processing reactive events in parallel then I don't think it is possible because the R interpreter is single-threaded. The way you manage parallelism in R is by spawning multiple R processes to split non dependent repetitive computations and consolidating results at the end but the reactive chain of events is serial.

Not exactly.
However ur explanation helps.
I wanted to know beyond this.

How actuality the work flow of execution happens. The flow I have mentioned is correct?

In general terms, yes, but if you are using a professional product you also have independent R process for each user (or maybe session, I'm not sure).