Package io.matita08
Class Utils
java.lang.Object
io.matita08.Utils
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final RandomShared random number generator used throughout the application.static final ThreadGroupThreadGroupwhere temporary tasks are executed. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidLoads a program file into the simulator's central memory asynchronously.static ThreadrunOnNewThread(Runnable run) Starts a new thread in the dedicated task group for executing background operations.
-
Field Details
-
rng
Shared random number generator used throughout the application. This provides consistent random behavior across all components. -
taskGroup
ThreadGroupwhere temporary tasks are executed. This provides better organization and allows for easier monitoring of background tasks.
-
-
Method Details
-
loadMC
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
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
-