I realize this is a subject of hot debate, but I'm interested in opinions that relate to my specific situation.
I want to learn the basics and fundamentals of programming, so I'm ... |
From the Java Language Specification:
The Java™ programming language is a general-purpose, concurrent, class-based,
object-oriented language.
What is a concurrent language?
|
First off let me apologize to the SO community for coming to you with something that ought to be so trivial. But I've been at this all day and I'm ... |
I'm writing a multi-threaded Java web crawler. From what I understand of the web, when a user loads a web page the browser requests the first document (eg, index.html) and as ... |
I need to write a simple datagrid form which allows users to edit cells - The problem is that different people can edit this at EXACTLY the same time so concurrency ... |
I have a CrystalReports XI Developer Full Product (Release 1) license and found out recently that it has a limitation on the number of concurrent requests it can process. ... |
Is the lock retained by the thread when context switch occur.
When we invoke a wait() the locks are given up by thread, what happens when theres a context switch.
Thanks
|
|
I have a question concerning graphs. Consider a graph with nodes and edges, each edge having a cost. The problem is to visit all nodes so that the sum of costs ... |
i want two use output from one applet as an input for another applet running in parallel..
|
I am practicing Java concurrency and using a chat client/server for learning.
Currently I need a pair of terminal windows (a receiver and a sender) per client. So really there is a ... |
I am getting an concurrent modification error while editing an XML file using Java in a JSP file. How is this caused and how can I solve it?
ElementFilter f = new ...
|
I'm developing a mobile application in Netbeans, but I'm running into problems when testing communication using SMS. In order to test this, I obviously need two emulators running, which I'm aware ... |
I want to be able to run an external program concurrently with my Java code, i.e. I want to start the program, then return control to the calling method while keeping ... |
I'm using solr version 1.4.0 with tomcat 6. I've 2 solr instances running as 2 different web apps with separate data folders. My application requires frequent commits from multiple clients. I've ... |
i want to monitor several log files concurrently .How to do in java ?
|
Our application needs multiple concurrent read write simultaneously and NRT searches. We have been using Solr till now and with minor tweaks in the solr configuration we have managed to sort ... |
Can some one please explain how CAS(compare swap) machine instructions are leveraged by java concurrent API's?
|
in our system, we have the contact database stored in PostgreSQL. We store quite a lot of information about each contact and these information is stored in many tables.
Our users ... |
I am trying to implement the Sieve of Erathostenes using 4cores i.e threads, because i am using the concurrent approach to solve this issue.
i have it done using a single thread ... |
I need to load test or simulate 2K connections to my web application to see how it handles load etc.
If I run apache bench on my laptop, I'm guessing it can't ... |
In Netty, does anyone know if the ChannelBuffer passed to a handler for an upstream event (after you cast it from ChannelEvent / or MessageEvent) will be concurrently written to by ... |
I was checking out page 100 and page 102 in Concurrent Programming in Java. I did not understand the following examples class Plotter{ // ... public void showNextPoint(){ Point p=new Point(); p.x=computeX(); p.y=compute(); display(p); } protected void display(Point p){ // somehow arrange to show p } } The book says that the above example is an hand-off protocal and is thread ... |
The nature of threads is that they let you have multiple processes running at once without a command in one having to wait on a command in another to finish. garbage collection runs this way as a daemon thread(as I have just learned from another post). So it will not stop other threads from processing while it is active. [ June ... |
Hi friends We know that threads run concurrently depending upon the scheduling mechanism. So when does this concurrent execution start? After the creation of the Thread object or when the run() method of the thread object is being executed. I mean, does the concurrency depends only on the start() method or does it depend on the run(). In case I create ... |
|
Usually I feel bad about adding extra dependencies to a project, but using util.concurrent is so natural it doesn't even feel like a dependency. Usually when I'm writing something multithreaded it doesn't take long at all before I come across a problem that's trivial to solve with util.concurrent and a pain to code by hand. It's an amazingly useful package. [ ... |
I've only used the JDK 5 stuff, but assuming it's pretty similar, here's how simple it can be: private void acceptClientRequests() { executor = Executors.newCachedThreadPool( ); while ( mRunning ) { try { executor.execute( new MessageHandler( mServerSocket.accept() ) ); } catch ( IOException e ) { throw new WikiException( ... ); } } } This loop puts a command into the ... |
|
Hello fellow programmers, i recently started working on threads and concurrent-parallel programming - which has not been going that well. I ve been trying to create a parallel bubble sort (meaning that in an array [10,5,3,1] the 10 should go after 1 and the 5 go between 1 and 10. Below is the basic bubble sort lagorithm, what confuses is me ... |
Originally posted by sudhana madhu: I have a class that contains 2 synchronised methods.I have 2 threads .Can these 2 threads concurrently execute these 2 methods(ie. First thread on First synchronised method and Second thread on Second synchronised method at the same time)If not why?? Whether two threads can run concurrently depends on the locks that they use to synchronize with. ... |
|
Hi I am using ClockDaemon.executePeriodically from Doug lea's library. in the call to above method we provide the period as an argument which specifies the period for timed call to the command. Here I have 2 queries regaring the method 1. what happens when the timer expires when the previous call to command is still not returned. 2. Does the library ... |
Hello, I'm having some difficulty with a project at work. Where the old program ran processes one at a time, I was charged with making it threadable.The downside is, it currently tries to run every thread at the same time. There are typically thousands, or tens of thousands, of threads to run, with each one taking several seconds to complete. (Yes, ... |
Hey There, Im looking for advice on how to tackle a problem. The problem is I want to create a simulation of a restaurant scenario using java to code it. I need to specify the concurrent processes, the sequential activities carried out by each actor and the constructs used to provide mutual exclusion and condition synchronisation. At the moment this is ... |
|
I am looking for a solution for the below problem. I want to have a thread that writes to a file and a thread that reads from the same file. Is this possible in java ? Can I ensure that data written by the writer thread will be seen by the reader thread ? I was thinking of using RandomAccessFile ,FileChannel ... |
public class PurgeDelayThread extends Thread{ private static PurgeDelayThread timerScheduler = null; private DelayQueue queue = null; private CodeskPurgeTask task3; private PurgeDelayThread() { queue = new DelayQueue(); } public static synchronized PurgeDelayThread getInstance() { if(timerScheduler == null) timerScheduler = new PurgeDelayThread(); return timerScheduler; } public void run() { while(true) { try { ScheduleDBPurgeDelay dbDelay = (ScheduleDBPurgeDelay)queue.take(); task3.purgeData(dbDelay.getMonths()[0]); addToQueue(dbDelay.getApplicationId(),dbDelay.getDay(),dbDelay.getHour(),dbDelay.getMonths()); } catch (Exception e) ... |
|
|
Hi, I am facing a problem when two user are simultaneously trying to insert a record in a table and both of them getting the same id. I am generating the id (pattern xxx-xxx) in my DAO layer and the way I am doing this is - first I am retrieving the last id created and incrementing it by one to ... |
Here's my problem: on a windows box I need to search for all the locations in any number of drives for a list of files or a single file. The list currently contains 100 files. My solution was to create a hash of the entire drive using the file name as the key and an arraylist of locations as the value. ... |
|
Hi, I'm trying to understand how threads work in Java. For this I use this small test program: public class Threads01 extends Thread { public static void main(String[] args) { new Threads01().start(); new Threads01().start(); } public void run() { for (int i = 0; i < 10; i++) { System.out.print(i + " "); } } } As output, I expect a ... |
|
I have a class (say class 'A' ) which has two methods [ m1() and m2() ] both are synchronised. Is it possible to call m1() and m2() of the same object of class 'A', by two separate threadts 't1' and 't2' concurrently: t1.m1() t2.m2() ? What will happen if m1() is synchronised and m() unsynchronised ? will again it will ... |
|
Hi, I am trying to find the Thread execution elapsed time.but it seems fine for only certail loops. Record.java import java.util.Map; /* * its an Model to hold the Parsed File Objects. */ public class Record { private String command; private Map cmdMap; public String getCommand() { return this.command; } public void setCommand(String command) { this.command = command; } public Map ... |
Hi Ranchers, I'm looking for a way to concurrently write to a log file. The sync blocks around the write in my current application are killing the through put of the system, getting rid of them would be a massive boon. I'm thinking of using a FileChannel to give the ability to write to a specific point in the file, calculating ... |
|
Say there is a method in my singleton. And, from my handler there are invocations to this method. my question is if there are 1000 concurrent hits to the singleton method, how is the situation handled, singleton being only one instance in the memory? - will the 1000 requests queued to be handled in sequence by the JVM - or will ... |
Hi, Lets say I have 10 transactions in a list where each batch consist of 5 transactions. If all the first 5 transactions is complete (batch 1), then only the next batch is allowed to proceed. Each transaction represents a thread in order to improve the performance as previously the list of transactions is processed one by one. My question is ... |
Hi, I have a code.In that i am trying to hit two URLs and getting and store their datas in separate objects.My question is will it be processing concurrently.please give me suggestion import java.net.*; import java.io.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.w3c.dom.Node; import org.w3c.dom.*; import org.w3c.dom.*; import org.xml.sax.InputSource.*; import org.xml.sax.*; import java.util.*; public ... |
Questions for the experts out here... I am very new to java... I treat it as C till now..but now i have to do multithreading for what i want to achieve... Any suggestions on how to perform multithreading in java... I got four programs , each of them gets a packet of data and check the first four bytes and compares ... |
|
|
public ReaderThread () {} public ReaderThread (CallerTest caller,int numWriters,Data data) { this.caller = caller; this.data = data; this.numWriters = numWriters; } public void run() { try{ while(!data.IsModified()) { data.getResultList().wait(); } mergeResults(); // this is some processing if(caller.getCounter() < this.numWriters) data.setModified(false); else { mergeResults(); caller.setFinalResult(finalResult); } } } catch(Exception ent) { log.error("The exception is in remote result reader ", ent); } } ... |
|
|
if the varibale cancelled in the above code is not declared as volatile then how would it transform to If the compiler can see that the while-condition variable isn't modified inside the loop, it is a standard compiler optimization called 'code-hoisting' to move the test out of the loop. 'volatile' tells the compiler the variable can be modified by other means ... |
Hi All, I have 4 threads that needs to concurrently write contents to different parts of a single Random Access file. Let me explain with an example. Say, the first thread will always write the first 10 bytes [byte 0 - byte 9] of this file. The 2nd thread will always write content from byte position 10 to 19 of the ... |
|
Hi all, I'd like to execute a periodic operation and stop the process if the operation response changes. For instance, my program can print "Hello world" and stop if it prints "Hello John": "Hello world" "Hello world" "Hello world" "Hello world" "Hello John" I know how to execute periodic actions but don't know how to stop it not using time parameter. ... |
There's no way to provide a code that deals with concurrency without knowing exactly what is needed, i.e. the whole scenario! Haven't you read my previous post? Will you synchronize reading access? i.e. when a thread is reading a Record, will others be able to read too? Or is it just writing access? Will be a writing mode, or you want ... |
Hi, Posted the following in the newbies forum (I'm one of them) but didn't get much help... Hope I have better luck around here! I'm having a bit of a problem with my first java development (hence I post in this forum). Just as general info, it is an applet that does ftp upload, which uses the apache library. Now, the ... |
Hi, I have to write a script to run multiple java files and c files concurrently. Say, A and C are java files and B is another binary executable file, I have to make sure they are run in the order A-B-C, then I was trying to run by using java A & ./B & java C But it turned out ... |
|
Hi, I'm using Java Logging API for logging. I'm planning to let the same application run on several servers, and they all should write things into the same log file in the file system. Is that possible? Are there any prerequisites to do that? I couldn't find any hints in the Logging API documentation nor in this forum. Thanks in advance! ... |
my aim is to run 2 threads concurrently...let s have a lokk at the following code.... import java.io.*; import java.util.*; class testtimer extends TimerTask { public void run() { System.out.println("timer started"); } } class testtimer2 extends TimerTask { public void run() { System.out.println("timer 2 started"); } } class maintimer { public static void main(String args[]) { testtimer t1=new testtimer(); testtimer2 t2=new ... |
Hi... I'm pretty new to Java; at uni, we are usually always given C programing assignements due to the nature of the course being very much low-level programming! but for this module, distributed systems, we have to learn about different distributed methods available! ...and obviously, one of the main ones, being RMI. The assignment is to write a simple RMI chat ... |
|
I want to run following jar as concurrent . but every application port must be different from other, Concurrent number will decide this port number. for (int k = 0; k <= CONCURRENT_NUMBER; K++) { String command = "java -jar x-server.jar -port DEFAULT_PORT" + k; Run.exec(command); } I want to run this application as concurrent,, help me.. |
You shouldn't just synchronize the consumers, the producer(s) should be sync'ed as well. The best object to synchronize on is the shared pool (queue) of produced objects. Producers should just wait while the consumers are busy with that queue and consumers should wait until there is something present in that queue they can consume. kind regards, Jos |
|
One thing that might help is if you try to lock the lower index first. So if thread 1 is trying to lock 3 and 7 and thread 2 is trying to lock 7 and 3, both can succeed in the first lock, but fail on the second one. If you re-arrange them so the lower index is locked first, that ... |
Is there any limitation to no of concurrent connections that can be opened using HttpURLConnection ? I want to send Data to a servlet using HttpURLConnection . so I am starting 30 threads(to simulate concurrency ) and inside run i am opening HttpURLConnection and send data using post and receive response and closing the connection .But i am getting below error ... |
Hi, I am working on a Java project where I use JNA to load a library (.dll) which implements several functions for a VME bus. The project is working fine without any other application needing to access the VME bus (i.e using the same dll). However, the project i'm working on is supposed to be runned with other applications using the ... |