My personal learning topic-wise project with inDepth concepts and comments/learning summary. (See unit-tests too) Readme is in progress.
The use of cache and synchronization on downloading names in this FileDownloadUseCase class is to ensure that the same file is not downloaded multiple times concurrently.The cachedFiles HashMap is used to store previously downloaded files, and the currentlyDownloadingFiles list is used to keep track of files that are currently being downloaded. Before starting a new download, the code checks if the file is already in the cache or if it is being downloaded by another thread. If it is already in the cache, the cached file is returned; if it is being downloaded by another thread, the code waits until the download is complete before starting a new download. This is achieved by using synchronized blocks and wait() and notifyAll() methods on a monitor object.
By doing this, the code ensures that only one thread downloads a file at a time and that files are not downloaded multiple times unnecessarily, which saves time and resources. See Unit-Tests too.
This is an example of a Producer-Consumer pattern, which is a common design pattern in concurrent programming, Demonstrates how multiple threads can work together in a synchronized manner to complete a complex task, and how the Producer-Consumer pattern can be used to manage shared resources (in this case, dishes) between these threads.
The BgThreadPoster class is useful in situations where you need to perform a time-consuming task in the background, such as loading data from a remote server, without blocking the main thread. Less overengineered than coroutines.
WhatsApp.Video.2023-04-24.at.09.17.53.mp4
Manually handling config changes and not let the activity destroy, Along with strategy-pattern applied on view logic.
It creates several large collections (ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap) and measures the time taken to perform various operations like adding and removing elements, iterating over elements, etc. The test is meant to compare the performance of different collections under different scenarios and help developers choose the appropriate collection type for their specific use case. See its unit-test here