Quick question, the answer is eluding me on the internet. Which is unusual. When we reference and call a sub/function from a class is it automatically started on a new thread or will it join the main thread? Cheers in advance.

Member Avatar
Member Avatar
+0 forum 3

Hi, I have learned that servlet containers like tomcat handle concurrency in web application. I just want to get a clear comfirmation whether I dont have to multithread my business logic classes/methods(e.g database connections) when I am developing servlet applications. Cheers!

Member Avatar
Member Avatar
+0 forum 1

I see this example frequently and thought I'd give it a shot but I've got something unexpected happening with my Queue. I have multiple threads utilizing my producer class but the output doesn't show that it is being written to by each thread. protected Queue<ProductMessage> prodQueue = new ConcurrentLinkedQueue<>(); @Override public void run() { while (true) { prodQueue.add(new ProductMessage(MP3Util.getRandomProduct(), new Date(), MP3Util.regionLookup(MP3Util.getState()))); System.out.println(Thread.currentThread().getName() + "Queue " + prodQueue.size()); try { Thread.sleep(2000); } catch (InterruptedException ex) { Logger.getLogger(ProductProducer.class.getName()).log(Level.SEVERE, null, ex); } } Thread p1 = new Thread(new ProductProducer()); Thread p2 = new Thread(new ProductProducer()); p1.start(); p2.start(); The output shows: Thread-1Queue 3 …

Member Avatar
Member Avatar
+0 forum 12

Hello all I am writing a solicitor allocation application that will be used by multiple users at one time. Because of this, the database needs to be updated with every change. This is my code when a solicitor is chosen for allocation: private void FindSolicitor(int type, bool stype) { table = ""; row = 0; int t = 0; bool f = false; string s = ""; char ctype = char.Parse(type.ToString()); if (!stype) { t = 0; for (int i = 0; i < sadset.Tables["Solic"].Rows.Count; i++) { if (sadset.Tables["Solic"].Rows[i]["State"].ToString() == "0" && ((sadset.Tables["Solic"].Rows[i]["Types"].ToString()).Contains(ctype))) { f = true; sadset.Tables["Solic"].Rows[i]["State"] = 1; …

Member Avatar
Member Avatar
+0 forum 1

public class Thread7 implements Runnable { public static void main(String r[]) { Thread t = new Thread(new Thread7()); t.start(); public void run() { System.out.println("C"); System.out.println("D"); } System.out.println("A"); try { t.join(); System.out.println("B"); } catch(Exception e){} } } Query1: On compiling this program I get "illegal start of expression" error pointing to public void run. But when I remove that block of code and place it outside main() the program compiles and runs successfully. What is the rule behind it? Query2: After I place run() outside main() the output is ACDB. What I don't understand is after t.start() is invoked shouldn't the …

Member Avatar
Member Avatar
+0 forum 1

Hey Guys i am doing a small project and i am using vb.net with MS access database. i am facing a Concurrency issue sometimes when i try to save data in the datagried view. i have added the datagried view by draging and drop the table from the data source. only one user is using the form to save data at one time. i think it works properly unless i moved from record to recored then it gives me an error. "Concurrency, 0 records updated from expected 1....." any one know how could i solv this issue??

Member Avatar
+0 forum 0

hi, how can i pervent from crontab concurrent run ??? thats mean when my crontab Take too long , with this crontab another crontab not runs... please help me ... best regards, amir

Member Avatar
Member Avatar
+0 forum 1

My understanding of this subject is - Two or more processes accessing a semaphore concurrently can cause Deadlock The provelms with semaphores is that you can forget to call the release method and it can cause deadlock Starvation Both processes can change the P and V counters of the semaphore and by doing put the process in an inconsistenet state. Is there anything anyone can add to this or have i just confused myself too much

Member Avatar
Member Avatar
+0 forum 6

Hello, I've got a problem with simultaneous placement of an order in a webshop. I will start off with a general description of the problem, and provide details after that. **The problem** Orders are stored in the table 'orders'. Each order has a BillNumber, which is obtained via a mysql routine (which basically takes the next available number). After The billnumber is obtained, the order is written away. However it looks like simultaneous calls of the billnumber routine sometimes give the same billnumber, when the order is not yet written away. Here is the routine that provides the next available …

Member Avatar
Member Avatar
+0 forum 13

Hello everyone I am new to this site. I have a university assignment in which I need to program a 2 player pacman game, using C and the Unix operating system. If more than 2 users have typed the command to run the program/s the users must wait in FIFO fashion until the current game ends, and then a new one starts. How can I divide this program into different files? could I have a map file which is shared, and a program file which reads the map file and moves the pacman? how can these be synchronised for a …

Member Avatar
+0 forum 0

Hello everyone! I am using python 2.6 on cygwin environment and wondering how could i prevent two python processes from writing to a file at the same time. The file that is shared between the python processes is an ini file and is accessed through ConfigObj module. The first python process is a daemon which runs indefinitely writing to the ini file, data on some random external conditions. The other python processes, start occasionally (one at a time), execute their code, write data on the ini file and stop. The command i want to ensure that is safely executed in …

Member Avatar
Member Avatar
+0 forum 5

Hi All, My knowledge of databases and Access is almost zero but none the less I have to try and solve a problem with a small home-grown Access database and hoping someone can help. I've done many searches and can't locate what I thought would be an easy answer. There was a posting on this site by cassyjack with an answer by jbennet that I thought for sure would fix our issue but no joy. We have a small database with a few Tables, a couple of Forms, and a couple of Queries and Reports. There are about 5 users …

Member Avatar
+0 forum 0

Hi, We are planning to upgrade an existing VB6 application to C# ( VS2008 ). ADO.Net follows more a disconnected strategy when accessing Data. I'm thinking about giving the Entity Framework a shot since using an ORM-tool is higly recommended if you want to speed up the development. And EF uses optimistic locking. How do you solve the ancient problem when 2 users open the same 'customer' for example. ADO.net suggests to check whether the record has changed when you save it using the conflict exceptions. In the old VB6 app we used to have 2 systems : - Keeping …

Member Avatar
Member Avatar
+0 forum 3

The End.