I'm using the java.util.zip library and ZipOutputStream in order to create a zip file of a directory and all the files and directories under it. In my application, it is ... |
I've got a java application on a windows machine which pins the CPU from time to time. Would like to run a utility to get an idea of how many ... |
I am really unfamiliar with working with threads, so I was hoping someone could help me figure out the best way to do this.
I have a JButton in my java application...when ... |
Threads are light weight processes, what does it mean?
|
Is there any sure-fire way to ensure Threads remain isolated from one-another, in Java? I've had an issue for a week and a half, where Threads implementing various 3rd party source ... |
I need to run N slow calculations (where N is a fairly large number) and would like to do so on M threads since the slow calculations have a good deal ... |
I am using a thread to capture stream output from a process, and then outputting that stream to the eclipse console. The question I have is when to terminate the thread ... |
|
I would like to design a simple application (without j2ee and jms) that can process massive amount of messages (like in trading systems)
I have created a service that can receive messages ... |
is there any way two threads within the same process can communicate without knowing anything about each other's interface ?
basically, one thread is a STOMP server, the other is a client. ... |
I want to write a program that has 2 threads , one thread continuously captures packets from the network and dumps them in a buffer every t seconds and the other ... |
In pseudocode, here's what I'm doing:
Process proc = runtime.exec(command);
processOutputStreamInThread(proc.getInputStream());
processOutputStreamInThread(proc.getErrorStream());
proc.waitFor()
However, sometimes processOutputStreamInThread doesn't see any output and sometimes it does. Roughly, the method creates a BufferedInputStream of the command's output and ... |
First , what is the difference between Thread and a Process in Java context?
and How Inter Process communication and Inter Thread communication is acheived in Java?
Please point me real time examples.
Thx
... |
I have following multi threaded environment scenario - Requests are coming to a method and I want to avoid the duplicate processing of concurrent requests coming. As multiple similar requests might ... |
I have a file of size 2GB which has student records in it. I need to find students based on certain attributes in each record and create a new file with ... |
I currently have a Java program that spawns 50 threads and the goal is to look at a directory that has many files being written to it and upload those files ... |
Say I am 1000 pop emails that I have to pull emails from.
I want to create a service, that utilizes muliple threads so I can pull email from multiple pop3 servers ... |
I'm getting hundreds of these process_reaper threads that build up over time in my application. Anyone have any idea what these may be? They seem to be in my use of ... |
some Function()
{
for(xxxxxx){
//a infinite loop or just a long code loading an running stuff from a list
...
|
while revising for an exam, i came across this simple question asking about rollbacks in processes. i understand how rollbacks occur, but i need some validation on my answer.
The question:
 |
A very direct question this time (I hope).
I'm not an experienced programmer and have learned it by myself, so I may lack some concepts.
I'm dealing with multithreading in Java and, as ... |
I am doing multithread processing for generating some products... i will create the products every 10 minutes..i have 2 threads .. first thread will wakeup every 10 minutes...
the second thread will ... |
I have a list of read only data which are a bunch of end points on the internet that I want to process. I was wondering is there any kind of ... |
I got a doubt while implementing threads, so thought of getting it cleared before i do some progress. I have a method from where the new thread is getting called and ... |
I was asked a question during interview today. First they asked how to provide Synchronization
between thread. Then they asked how to provide Synchronization between process, because I told them, the variable ... |
I have a Process in Java, tat takes 4 mins to complete. 10 such process lined up takes around 40 mins. If i Thread the processes like One thread for a ... |
I read some tutorial about threads and processes, it is said that the processes be scheduled by operating system kernel, and the threads can be managed and scheduled in a user ... |
I have created a Java GUI application which functions as a wrapper for many low level external processes. The utility works as is, but is in desperate need of one ... |
I have just created a process through an exec() call and I am now using
its .waitFor() method. I need to catch an InterruptedException but I am
not sure what I should ... |
I want to continuously check a table in the database to see whether a new row has been added to it. This runs as a back ground process. I think ... |
Assuming that Runtime.getRuntime().addShutdownHook(new Thread() has been set up correctly, how can the ShutdownHook thread be invoked when a Java application window (JFrame) is closed (in this case the only window) and ... |
We have a Java application that processes requests. Naturally, there is a thread pool with threads named with some insignificant names like "processor-1", "processor-2" etc. We are wondering whether it's a ... |
I have a small question about threads.
On Unix systems, we have nice, which can be used to set priorities
processes.
OK, on ??my system, I call some external processes, however, ... |
I'm designing a server-side application that takes an image from a user, processes it, and sends it back over the network. Since the network connection might be quite slow, I'd like ... |
I'm considering separating a task from my main program to a new (java) thread. The second task can be resource consuming (which raises concerns about the "wellbeing" of the main program).
Is ... |
I've had a look at the posts about destructors in Java and have learnt that Java does not have them but I am confused about what I need to do in ... |
Are the RMI requests handled per process or per thread on the server side?
|
What data structures do I use to implement the following logic?
- read() is an asynchronous method that queues some workload
- Only one workload may run at a time.
- The first thread to queue a ...
|
The title says all!
I want to get the process ID of a Thread to see how much memory it takes. ;)
Thanks guys (:
|
I have a project made using Java.
I have a complex processing, something like from one single process i create 10 different threads, then the process waits for the other threads ... |
I am running Ubuntu server edition and I wanted to take a thread dump of Tomcat.
So, I first tried to find out which PID tomcat uses:
$ jps -l
5809 sun.tools.jps.Jps
But it's not ... |
I have an application with a few threads that manipulate data and save the output in different temporary files on a particular directory, in a Linux or a Windows machine. These ... |
I have a relatively simple program that currently uses 1 thread (main). The application takes about 30 minutes to complete. However, according to Task Manager, it is only using ... |
How to create asynchronous messages from worker threads to the managing thread. The framework is below. In the snippet, Worker implements Runnable, and threadManager is ExecutorService. The Worker ... |
my application has a queue with " outgoing network packets" (A POJO with a ByteBuffer and a SocketChannel) inside, consumed by a single thread that writes the data to the SocketChannel.
I ... |
I am trying to make a Java program which will run several other unrelated Java programs, specifically a Minecraft server.
Currently, I am trying to work out how to end a java.lang.Process ... |
Methods like yield(),wait() are provided for IPC in java.Thus they cater to different threads inside the same ONE process.Multiple concurrent processes are supported in modern os's in process control blocks are created by the os track their addresses.Sharing of data is expensive between processes,the familiar consumer-producer processes ascompared to threads within a single process coz of faster context switching.Hope it helps. ... |
Mukesh, In a nutshell, a process can contain multiple threads. In most multithreading operating systems, a process gets its own memory address space; a thread doesn't. Threads typically share the heap belonging to their parent process. For instance, a JVM runs in a single process in the host O/S. Threads in the JVM share the heap belonging to that process; that's ... |
Hi Angela, I think u r confused. There is nothing like how thred will come to know it's upto you what u want from a thread to do for you. If u wish that ur thread should wait for messages u can give code for it to listen at the specific port number using sockets here thread will keep on waiting ... |
Hi guys! I am facing a real life trouble here.. from my program I want to initiate some processes which should continue even after my program which started them goes off In short, I want to achieve something like this public class Launcher{ main(){ Runtime.getRuntime().exec("java -cp cpofMyClasspFile MySocketServerClass"); } } now when I do a ^c on the command prompt to ... |
To understand the basic difference between thread and a process u have to consider various points: 1. Each process has - A. Register context - value of CPU register when the process is executing. B. Data context - The code that the process is executing. C. Stack Context - Various values of function call returns and local variables etc. Now, no. ... |
Hi everyone, I am going to be writing a program that spawns a single thread to do the basic processing of the program, while the event dispatch thread listens to user events. As the loop that the basic processing is performed in is not trivial, is the only way to exit gracefully from this thread to poll some variable that is ... |
A decent book: Concurrency, State Models & Java Programs by Jeff Magee & Jeff Kramer 'Process' can be used to refer to an operating system process, which is a unit of resource allocation both for CPU time and memory in a system. An os process is characterized by: -a data segment -a code segment -multiple stacks, one for each thread The ... |
A thread shares its memory space with all other threads living inside the same process. On one hand, this makes it easy for threads to interact with each other as they can simply share data (objects). On the other, if a thread crashes badly it can easily take all other threads down with it. Because threads share so many resources with ... |
I'm trying to design a process for an application using threads. I am having trouble figuring out the best way to do things. I have an application that will connect to a database, then periodically check for updates and send messages based on the updates. I am using a TimerTask object to check for and process the updates. My goal is ... |
|
Hi all I've got a litte problem. I have an ap that runs ans starts another java app as a daemon on a server I am starting the daemon app in the following way rT.exec("cmd /c java -cp {all needed libs} {daemon app}"); my questions is: 1. Will this process keep runing on the unix system after i log off (can ... |
Hello, How can i get the process ID that would be allocated by the JVM to any particular thread ? ie i've a java thread which invokes another thread and the INVOKING thread need to know the PROCESS ID of INVOKED thread. That means the invoked thread should return its own process id to the thread that invoked it. is there ... |
Hi, This is the simple representation of the situation: a producer (Servlet) produces queue elements and enqueues the elements (the queue is a Singleton datastructure). A consumer dequeues the elements for processing. The produces could produce elements all the time (in a very extreme situation), and should always be able to enqueue. The consumer is a Thread that is always running. ... |
Hi, I read in my college days that a Thread is a lighter process , is'nt that true? I had a discussion earlier with a collegue who says , you cannot even call a thread as a lighter process . and i believe that a thread has to start from a process. I know some things likes the context switch for ... |
If you want to call another thread from servlet, it makes sense for servlet not to wait and return from doPost ( or doGet ) method. The idea of the background processing in servlet is to allow servlet code to return while the background thread will continue. Jason Hunter book on "Java Servlet Programming" has a very good example on servlet ... |
In common usage (but not legally binding, so you will find exceptions) a process is a large-grained thing started by the operating system. When we start a Java program, the OS starts the JVM as a process. A thread is a finer grained thing inside the process, managed by the process. So the JVM can manage many threads inside its process. ... |
|
|
|
Hi All, I am trying to call another software from my java program. And the source code is: Runtime r = Runtime.getRuntime(); Process p = null; try { p = r.exec("racer.exe"); }catch (Exception e) { System.out.print(e.getMessage()); } The software "racer.exe" must be started in MS-DOS environment and I compile and execute my java program also in MS-DOS environment. Now the problem ... |
Hi all, I'm running a script on UNIX from my java application using Process p = Runtime.getRuntime().exec("/bin/sh " + cmdfilename); p.waitFor(); However it doesn't always run successfully so I want to be able to trace an output /errors thrown from the process ... how should I go about that ? On a separate note ... the script I'm running is to ... |
HI all I want to speed up the processing time of my batch process which is taking hours for processing 10000+ records.I am using stateless session beans with DAO Beans to fetch\write Records in to data base .I use Prepared Statements for record insertion with more than 100 prepared statements for each record insertion. Do we have any other technique to ... |
Hi Friends, I am using Runtime class in my application.It creates JAR & EAR Files.For that I used Runtime class. Here my peace of code Pls help me what is worng in this code. try { String stmt = "jar -Mcvf " + ejbJarName + " META-INF/MANIFEST.MF " +" META-INF/ejb-jar.xml " + " com"; Process stmtProcess = java.lang.Runtime.getRuntime().exec(stmt); if (osname.startsWith("Windows")) { ... |
You can use the Timer class in the library to run a task at scheduled times. Timer is a normal Java thread with a loop in the run() method and it can be set to never end. It would be nice to have a clean way to terminate it. Ctrl-C works, but a UI or a remote interface - eg a ... |
I work on applications that use similar environment (AIX and Jdk1.3.1). If your java application is starting threads as soon as you start your application, then for a breif time (while your program is spawning threads), it shows that those threads as 'sub-processes'. you will know which process is the actual process and which are 'subprocesses/threads' by looking at their process ... |
Hi guys, hope you can give me a few ideas where to look to solve this problem: I have a component that recieves a message. I have an executor with a method execute() that is called by part of a framework. The execute method waits until the component recieves a message and notifies listeners (eg the executor). I'm trying to then ... |
Hi all, the functionality that i am trying to implement is: 1. Read file 2. validate each record(line). 3. store record to DB. I want record processing should happen in parallel. What I meant by this is, read a file by thread A, handle the line(record) to sub thread to validate and store in DB), while sub thread busy doing validation ... |
Hi, Sorry if this as been already answered but I could not find the information. I have 3 part in my project. A j2me device A servlet A Asp control that send fax. So I call my servlet with my j2me device, my device wait on the getResponseCode(), my Servlet do the process in the end it call the asp control ... |
Hi Thank you for reading my post I have a question about threading , i now how to initiate a thread and use it , but what i do not know is : I have an array of objects (i am not allowd to change those objects class structure) i want to use several threads to process all this objects instead ... |
Tom, I might have misread your question. You never stated that you wanted to create new threads. And this question may just be how to use the sleep() method of the Thread class. If this is true... The sleep() method is static and affects the current thread. There is no reason to create a new thread object -- it can be ... |
|
In my application I kick off a batch file that runs osql commands and executes scripts for our dbas. There are some scripts that I can run in parallel and so I am now creating threads to run those. However I still see a serialized execution of threads one after another. Is this even possible to kick off processes (using Runtime.exec) ... |
Im having an odd problem with thread pooling. I have a class (lets call it Sender) that runs through a variety of data objects, spawning threads to process each one. I created a class that implements Runnable and, of course, implements the run() method. When it is instantiated, a reference to Sender is passed to it. At the end of run(), ... |
I have a desktop application. I want to create a background thread that will call some functions or wait for an event to occur, without blocking the main thread (the user must be able to access the main form, click buttons etc.). The background thread is hidden for him. And when the function called is finihed or specified event occurs, the ... |
A favorite interview question is: What is the difference between Process and Thread. Here is my answer: Process: An instance of a program; Executed in own address space Independent entity to which system assigns resources CPU time, memory Cannot access variables or other data structure in another process Process communicate using inter-process mechanisms like files, pipes, sockets Thread Is ... |
|
dear guys, i don't think there is any way of renaming a post, so i created a new one whichh more accurately describes my question. my previous post was titled "sending html to the browser whilst an intensive operation proceeds ". my question is now... is it possible to start a new thread to handle the retrievel of the data. This ... |
Hi all, I want to design a servlet that monitors a particular task continously in a loop. For this I am creating a thread that will run in a continous loop monitoring the task. I want to make this a background thread that will exist and keeps on doing it's job even when the servlet is unloaded? How can I do ... |
hi folks, i have an rmi server running which extends UnicastRemoteObject and upon startup, before any clients have connected, it spawns about 15 processes, 1 parent and 14 children. the same thing happens when i start the rmiregistry (1 parent, 12 children). i'm running on suse 9.0 using jdk 1.4.1_06. i don't believe i've seen this sort of behavior before and ... |
Usually process means a "heavy weight" program context started by the operating system. If you start NotePad three times, each one is a process. You can see three applications and three processes in Task Manager. Threads are "light weight", meaning it's a lot less work to set one up, manage it and tear it down. A single process can manage multiple ... |
To overgeneralize ... Processes are started by the operating system. There is quite a bit of startup and teardown overhead. They offer good safety and isolation from each other, the downside of which is it's harder to make them communicate with each other. Threads are managed by a program running in a process. They are lighter weight to startup and teardown, ... |
A thread in computer science is short for a thread of execution. Threads are a way for a program to split itself into two or more simultaneously (or pseudo-simultaneously) running tasks. Threads and processes differ from one operating system to another, but in general, the way that a thread is created and shares its resources is different from the way a ... |
A Process object is good for only a few things: - interaction with the process using the input, output and error streams - terminating the process - waiting for the process to finish before doing anything else - retrieving the exit code of the process That's why there are only methods for these operations. |
Both threads and processes are methods of parallelizing an application. However, processes are independent execution units that contain their own state information, use their own address spaces, and only interact with each other via interprocess communication mechanisms (generally managed by the operating system). Applications are typically divided into processes during the design phase, and a master process explicitly spawns sub-processes when ... |
|
Hello friends, I am testing my own 'desktop application' which processes bulk user data with the help of multithreading with each thread processing one user's data. The number of threads running at a time is configurable and I have set it to a value which gave us best overall throughput. Out of blue, I had setup multiple instances running with the ... |
|
|
Hi. so, what i want to do is.. for example, if there is class1.java, class2.java and class.java, and each java source file has main classes, and when compiled, load as an individual program. let's say there is a deque in class.java. what i want to do is to allow class1.java and class2.java accesses to the same deque(same memory space; i am ... |
Hi All, I am working on a Rule Engine Application, which is implementing Apache Lucene for indexing. The performance of this application is poor and incosistent. We are trying to findout a bottleneck which is hitting the performance. This application creates threads to process the records and for each 1lac records, it creates one thread. Now when I am running a ... |
Hi I am currently running a java application starting with 50 threads at a time. Every threads also include numerous page downloads from the web, so at start (when all the 50 threads are running), the process is very fast. When nearly 40 threads finish their operations and only the remaining threads are working....it takes a lot of time ....which also ... |
For the program I am writing, I must not use threads at all, I can only use processes. I am trying to understand where to perform operations on the data once a child process is created. Here is the code: public static void main(String args[]) { try { // spawn child Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("java child"); ArrayList ... |
Hi, I am planning for a database synchronization tool which need to move a set of data from production server to test server.I am expecting load of some 50,000 to 1,00000 records from various tables. If i intend to do it in a generic way to handle more load than that, 1) Do i need to create multiple threads from a ... |
I am new to Java Threads. I would like to use threads to speed the processing of the following program. This is the pojo that does the work: import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; import java.util.ArrayList; import java.util.HashMap; public class FileFinder { private File originalFileObject; private File fileObject; private HashMap allFiles; private ArrayList duplicateFiles; private ... |
Hi, I am new to coderanch forum.I have 3 years of Java exp and i never worked on threads. Here is the high level overivew of my code that I have created. Create Executor service for Producer to pick up the records using Linked blocking queue.. Once the records have been taken up by the producer, it will form ... |