Package io.matita08

Class Utils

java.lang.Object
io.matita08.Utils

public class Utils extends Object
Utility class providing common functionality for the CPU simulator. This class contains helper methods for file operations, threading, and other shared utilities used throughout the application.

Key features:

  • File Loading: Loads program files into the simulator's central memory
  • Thread Management: Provides utilities for running tasks on separate threads
  • Random Number Generation: Shared random number generator for consistent behavior

The class uses a dedicated thread group for temporary tasks to provide better organization and debugging capabilities. All file operations are performed asynchronously to avoid blocking the GUI thread.

Since:
1.0
  • Field Details

    • rng

      public static final Random rng
      Shared random number generator used throughout the application. This provides consistent random behavior across all components.
    • taskGroup

      public static final ThreadGroup taskGroup
      ThreadGroup where temporary tasks are executed. This provides better organization and allows for easier monitoring of background tasks.
  • Method Details

    • loadMC

      public static void loadMC(File f)
      Loads a program file into the simulator's central memory asynchronously. This method starts a new background thread to perform the file loading operation without blocking the GUI.

      The file is parsed line by line, with each line representing a memory value. Lines starting with "?" or empty lines are treated as undefined values. Numeric lines are parsed and stored as defined values. Invalid numeric formats are treated as undefined values.

      Parameters:
      f - the file to load into central memory
      See Also:
      • loadMCImpl(File)
    • runOnNewThread

      public static Thread runOnNewThread(Runnable run)
      Starts a new thread in the dedicated task group for executing background operations. Each thread is given a unique name for easier identification during debugging.
      Parameters:
      run - the task to execute on the new thread
      Returns:
      the started Thread object