I cannot make this stop watch:- work. pls help. I have no clue of what is required in the test processBuilder.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I cannot make this stop watch:- work. pls help. I have no clue of what is required in the test processBuilder.
lwigfulltiffany (March 27th, 2019), rarberryrock (March 26th, 2019), srgisjeff (March 26th, 2019)
Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.
Please simply post your code correctly using code or highlight tags per the above link rather than attaching it.
lwigfulltiffany (March 27th, 2019), rarberryrock (March 26th, 2019), srgisjeff (March 26th, 2019)
still trying to figure out how files are easily implemented here.
lwigfulltiffany (March 27th, 2019), rarberryrock (March 26th, 2019), srgisjeff (March 26th, 2019)
What's your question? How can we help?
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
Hello everyone,
I have tried several methods of creating threads to get this stop watch working. created a thread class which implements runnable but it seems not helping. Really can't get this working. pls i know it involves a couple of codes but am totally blank right now.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
In order to not block the command shell when a process is created we
will create a thread that manages the running of each application.
Create a new class that implements the Runnable interface and which
takes the string command as input in the constructor. This will be the
class that calls ProcessBuilder in its run method. Observe that since we
need to have access to the string command in the run method of the
thread, we need to store this when the thread is created. In the run
method we add the code from the old version of the method
createProcess and modify the method createProcess as follows: Instead
of calling ProcessBuilder in this method you should create an instance
of the Runnable class. Then start the Runnable as a thread.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
Please don't start duplicate threads. Threads merged.
Answer questions, post details, do what you're asked to do, and keep the dialog going. Source files end with a .java extension. What are the .txt files you've attached? Copy your source files and paste them directly into a post using code or highlight tags as described in the link I provided earlier.
Then explain what help you need. We're not going to read your assignment, all of the code you've attached, and figure out what is needed to get something "working". Tell us what you've done, what results you've gotten, how those results are unsatisfactory (what should they be), why you think that might be, and then ask what what to do to modify the code so that it meets the requirements.
lwigfulltiffany (March 27th, 2019), rarberryrock (March 26th, 2019), srgisjeff (March 26th, 2019)
Both processes and threads are independent sequences of execution. The typical difference is that threads run in a shared memory space, while processes run in separate memory spaces.
I'm not sure what "hardware" vs "software" threads you might be referring to. Threads are an operating environment feature, rather than a CPU feature.
Erlang uses the term "process" because it does not expose a shared-memory multiprogramming model. Calling them "threads" would imply that they have shared memory.[COLOR="Silver"]
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
Process
Processes are heavyweight operations
Each process has its own memory space
Inter-process communication is slow as processes have different memory addresses
Context switching between processes is more expensive
Processes don’t share memory with other processes
Thread
Threads are lighter weight operations
Inter-thread communication can be faster than inter-process communication because threads of the same process share memory with the process they belong to
Context switching between threads of the same process is less expensive
Threads share memory with other threads of the same process
--- Update ---
Process
Processes are heavyweight operations
Each process has its own memory space
Inter-process communication is slow as processes have different memory addresses
Context switching between processes is more expensive
Processes don’t share memory with other processes
Thread
Threads are lighter weight operations
Inter-thread communication can be faster than inter-process communication because threads of the same process share memory with the process they belong to
Context switching between threads of the same process is less expensive
Threads share memory with other threads of the same process
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
The primary difference is that threads within the same process run in a shared memory space, while processes run in separate memory spaces.
Threads are not independent of one another like processes are, and as a result threads share with other threads their code section, data section, and OS resources (like open files and signals). But, like process, a thread has its own program counter (PC), register set, and stack space.
Advantages of Thread over Process
1. Responsiveness: If the process is divided into multiple threads, if one thread completes its execution, then its output can be immediately returned.
2. Faster context switch: Context switch time between threads is lower compared to process context switch. Process context switching requires more overhead from the CPU.
3. Effective utilization of multiprocessor system: If we have multiple threads in a single process, then we can schedule multiple threads on multiple processor. This will make process execution faster.
4. Resource sharing: Resources like code, data, and files can be shared among all threads within a process.
Note: stack and registers can’t be shared among the threads. Each thread has its own stack and registers.
5. Communication: Communication between multiple threads is easier, as the threads shares common address space. while in process we have to follow some specific communication technique for communication between two process.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
5. Communication: Communication between multiple threads is easier, as the threads shares common address space. while in process we have to follow some specific communication technique for communication between two process.
This is a good point to make. The network thread has to communicate with that person's thread to actually know what it is doing. They will be sharing files across the internet to actually make this happen. Stop watch work. That common address space can be a buffer on their computer or it can take place on your computer. It does not matter. The point to all of this is that each thread is in sinc with each other over the internet.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
5. Communication: Communication between multiple threads is easier, as the threads shares common address space. while in process we have to follow some specific communication technique for communication between two process.
This is a good point to make. The network thread has to communicate with that person's thread to actually know what it is doing. They will be sharing files across the internet to actually make this happen. Stop watch work. That common address space can be a buffer on their computer or it can take place on your computer. It does not matter. The point to all of this is that each thread is in sinc with each other over the internet.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
process is nothing but executing program...one or more threads executing same time ....is called multi threading .operating system allocates processeser time....
Last edited by Muneera123; February 6th, 2019 at 01:33 AM.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)
Old thread closed
If you don't understand my answer, don't ignore it, ask a question.
lwigfulltiffany (March 27th, 2019), srgisjeff (March 26th, 2019)