concurrent-programming

All goroutines are asleep - deadlock! ----— Error

十年热恋 提交于 2019-12-12 08:16:18
问题 I want to write three concurrent go routines that sends integers to each other. Now, my code is compiled properly, however after first execution it gives error "all goroutines are asleep - deadlock!". I tried to find the error but I could not able to find any error in code logic.Can anybody help me to find the mistake with my code. My code is given below. Thanks in advance. package main import "rand" func Routine1(command12 chan int, response12 chan int, command13 chan int, response13 chan

ORACLE PLS-00201: identifier 'VAT_REGISTER_AP.VAT_REG3' must be declared

送分小仙女□ 提交于 2019-12-12 03:17:09
问题 I am new to oracle EBS. I have defined a concurrent program. Where i am calling package function VAT_REGISTER_AP.Vat_REG3 . Below is the syntax create or replace PACKAGE VAT_REGISTER_AP AS FUnction VAT_REG3--(P_STARTDATE IN DATE,P_EndDate IN Date,P_Legal_Enitity_ID IN NUMBER) RETURN sys_refcursor; END; create or replace PACKAGE BODY VAT_REGISTER_AP AS FUNCTION VAT_REG3--(P_STARTDATE DATE,P_EndDate Date,P_Legal_Enitity_ID IN NUMBER) RETURN sys_refcursor IS R_RET sys_refcursor; BEGIN OPEN R_RET

Way to check in C/C++ if a file is in use?

元气小坏坏 提交于 2019-12-12 01:43:33
问题 Is there any way to check if a file is in use in C/C++? Or do I have to ALWAYS implement a lock/semaphore to prevent simultaneous access of any file by multiple threads/processes? If we consider Linux, and the following scenario: I want to transfer,in chunks, the contents of a file stored in device A to another device B through RS-232 communication, using a pre-defined communication framework. When the request for this transfer comes, I want to verify the file is NOT being used by any process

Deadlock Error in Mutually Concurrent Go Routines

给你一囗甜甜゛ 提交于 2019-12-11 23:08:47
问题 I have three concurrent go routines like below, func Routine1() { mutex1.Lock() do something mutex2.Lock() mutex3.Lock() send int to routine 2 send int to routine 3 * Print Something * mutex2.Unlock() mutex3.Unlock() receive ints do something mutex2.Lock() mutex3.Lock() send int to routine 2 send int to routine 3 Print Something mutex2.Unlock() mutex3.Unlock() do something receive ints mutex1.Unlock() wg.Done() } func Routine2() { mutex2.Lock() do something mutex1.Lock() mutex3.Lock() send

How to concurrently modify a Vector

若如初见. 提交于 2019-12-11 19:28:26
问题 I have to ensure while iterating the Vector; there is no update on that Vector to avoid ConcurrentModificationException . I can use concurrent collection. But i just want to give a try on Vector. Below is the code I have written. public class TestConcurrentModification1 { Vector a = new Vector(); public static void main(String[] args) { final TestConcurrentModification1 obj = new TestConcurrentModification1(); new Thread(){ public void run(){ for(int i = 0; i < 5; i++){ try { Thread.sleep(1);

Start/Suspend/Resume a method in Java [duplicate]

孤街浪徒 提交于 2019-12-11 09:43:03
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Start/Suspend/Resume/Suspend … a method invoked by other class I want to implement an Anytime k-NN classifier but I cannot find a way to call the "classify(...)" method for a specific amount of time, suspend it, get the available results before the method was suspended, resume the method for a specific amount of time, suspend it, get the available results before the method was suspended, and so on... Thanks in

Java- Why this program not throwing concurrent Modification exception

谁说我不能喝 提交于 2019-12-10 15:12:54
问题 I am trying to induce a concurrent modification exception by accessing a HashMap instance variable reference, but this program is not throwing the error. Appreciate if you could help me to understand. package Threads; import java.util.HashMap; public class ProducerConsumer { private HashMap<String, String> sharedMap = new HashMap<String,String>(); public void putMethod(){ for (int count=0; count<100; count++) { System.out.println("Adding into sharedMap:"+count); sharedMap.put(Integer.toString

why doesn't this erlang code work?

旧时模样 提交于 2019-12-08 03:07:51
问题 fib(N)-> P1 = spawn(fun concFib:conFib/0), P2 = spawn(fun concFib:conFib/0), X=rpc(P1,N-2),Y=rpc(P2,N-1),X+Y. conFib()-> receive {Client,N} -> Client ! regfib(N) end. rpc(Pid,Request)-> case erlang:is_process_alive(Pid) of true -> begin Pid ! {self(),Request}, receive {Pid,Respond} -> Respond end end; false -> io:format("~w process is dead.",[Pid]) end. regfib(N)-> case N<2 of true -> 1; false -> regfib(N,1,1,1) end. regfib(N,N,X,_)-> X ; regfib(N,M,X,Y)-> regfib(N,M+1,X+Y,X). The idea is to

Haskell, Channels, STM, -threaded, Message Passing

岁酱吖の 提交于 2019-12-07 05:47:45
问题 I am trying to use channels/STM to implement message passing in Haskell. Maybe this is a terrible idea, and there is a better way to implement/use message passing in Haskell. If this is the case, do let me know; however, my quest has opened some basic questions on concurrent Haskell. I have heard great things about STM, and in particular the implementation in Haskell. Since it supports reading to and writing from, and has some safety benefits, I figured one would start there. This brings up

Code examples that use fine grained locks (JCR Jackrabbit?)

混江龙づ霸主 提交于 2019-12-06 13:53:41
问题 I'm doing an academic research in trying to develop a programming tool that assists in implementing fine-grained locking functions, for concurrent programs that maintain tree-like data structures. For example, the programmer may write some functions that receive a tree root-node and modify the tree (by traversing on some routes and adding/removing nodes), and the tool will help him to find where in the code nodes should be locked and where they can be released - so the functions could be