Search Results

Search found 265 results on 11 pages for 'ravi chandra'.

Page 1/11 | 1 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • Difference in output from use of synchronized keyword and join()

    - by user2964080
    I have 2 classes, public class Account { private int balance = 50; public int getBalance() { return balance; } public void withdraw(int amt){ this.balance -= amt; } } and public class DangerousAccount implements Runnable{ private Account acct = new Account(); public static void main(String[] args) throws InterruptedException{ DangerousAccount target = new DangerousAccount(); Thread t1 = new Thread(target); Thread t2 = new Thread(target); t1.setName("Ravi"); t2.setName("Prakash"); t1.start(); /* #1 t1.join(); */ t2.start(); } public void run(){ for(int i=0; i<5; i++){ makeWithdrawl(10); if(acct.getBalance() < 0) System.out.println("Account Overdrawn"); } } public void makeWithdrawl(int amt){ if(acct.getBalance() >= amt){ System.out.println(Thread.currentThread().getName() + " is going to withdraw"); try{ Thread.sleep(500); }catch(InterruptedException e){ e.printStackTrace(); } acct.withdraw(amt); System.out.println(Thread.currentThread().getName() + " has finished the withdrawl"); }else{ System.out.println("Not Enough Money For " + Thread.currentThread().getName() + " to withdraw"); } } } I tried adding synchronized keyword in makeWithdrawl method public synchronized void makeWithdrawl(int amt){ and I keep getting this output as many times I try Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Ravi is going to withdraw Ravi has finished the withdrawl Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw Not Enough Money For Prakash to withdraw This shows that only Thread t1 is working... If I un-comment the the line saying t1.join(); I get the same output. So how does synchronized differ from join() ? If I don't use synchronize keyword or join() I get various outputs like Ravi is going to withdraw Prakash is going to withdraw Prakash has finished the withdrawl Ravi has finished the withdrawl Prakash is going to withdraw Ravi is going to withdraw Prakash has finished the withdrawl Ravi has finished the withdrawl Prakash is going to withdraw Ravi is going to withdraw Prakash has finished the withdrawl Ravi has finished the withdrawl Account Overdrawn Account Overdrawn Not Enough Money For Ravi to withdraw Account Overdrawn Not Enough Money For Prakash to withdraw Account Overdrawn Not Enough Money For Ravi to withdraw Account Overdrawn Not Enough Money For Prakash to withdraw Account Overdrawn So how does the output from synchronized differ from join() ?

    Read the article

  • SQLAuthority Guest Post – Lessons from Life and Work by Srini Chandra (Author of 3 Lives, in search of bliss)

    - by pinaldave
    Work and life are confusing terms together. How can one consider work outside of life. Work should be part of life or are we considering ourselves dead when we are at work. I have often seen developers and DBA complaining and confused about their job, work and life. Complaining is easy and everyone can do. I have heard quite often expression – “I do not have any other option.” I requested Srini Chanda (renowned author of Amazon Best Seller 3 Lives, in search of bliss (Amazon | Flipkart) to write a guest post on this subject which developer can read and appreciate. Let us see Srini’s thoughts in his own words. Each of us who works in the technology industry carries an especially heavy burden nowadays. For, fate has placed in our hands an awesome power to shape our society and its consciousness. For that reason, we must pay more and more attention to issues of professionalism, social responsibility and ethics. Equally importantly, the responsibility lies in our hands to ensure that we view our work and career as an opportunity to enlighten and lift ourselves up. Story: A Prisoner, 20 years and a Wheel Many years ago, I heard this story from a professor when I was a student at Carnegie Mellon. A man was sentenced to 20 years in prison. During his time in prison, he was asked to turn a wheel every day. So, every day he turned the wheel. At times, when he was tired or puzzled and stopped turning the wheel, he would be flogged with a whip. The man did not know anything about the wheel other than that it was placed outside his jail somewhere. He wondered if the wheel crushed corn or if it ground wheat or something similar. He wondered if turning the wheel was useful to anyone. At the end of his jail term, he rushed out to see what the wheel was doing. To his disappointment, he found that the wheel was not connected to anything. All these years, he had been toiling for nothing. He gave a loud, frustrated shout and dropped dead. How many of us are turning wheels wondering what it is connected to? How many of us have unstated, uncaring attitudes towards our careers? How many of us view work as drudgery, as no more than a way to earn that next paycheck? How many of us have wondered about the spiritually uplifting aspect of work? Can a workforce that views work as merely a chore, be ethical? Can it produce truly life enhancing technology? Can it make positive contributions to the quality of life of a society? I think not. Thanks to Pinal and you, his readers, for giving me this opportunity to share my thoughts in a series of guest posts. I’d like to present a few ways over the next few weeks, in which we can tap into the liberating potential of work and make our lives better in the process. Now, please allow me to tell you another version of the story that the good professor shared with us in the classroom that day. Story: A Prisoner, 20 years, a Wheel and the LIFE A man was sentenced to 20 years in prison. During his time in prison, he was asked to turn a wheel every day. So, every day he turned the wheel. At first, his whole body and mind rebelled against his predicament. So, his limbs grew weary and his mind became numb and confused. And then, his self-awareness began to grow. He began to wonder how he came to be in the prison in the first place. He looked around and saw all his fellow prisoners also turning the wheel. His wife, his parents, his friends and his children – they were all in the prison too, and turning their own wheels! He began to wonder how this came about. As he wondered more and more, he began to focus less on his physical drudgery and boredom. And he began to clearly see his inner spirit which guided him in ways that allowed him to see the world with a universal view. His inner spirit guided him towards the source of eternal wisdom and happiness. He began to see the source of happiness in everything around him – his prison bound relationships, even his jailers and in his wheel. He became a source of light to those around him. His wheel jokes and humor infected them with joy and happiness. Finally, the day came for his release from jail. He walked calmly outside the jail and laughed aloud when he saw that the wheel was not connected to anything. He knelt down, kissed it and thanked it for the wisdom it taught him. Life is the prison. The wheel is your work. Both are sacred. Both have enormous powers to teach us wisdom and bring us happiness. Whether we allow them to do so, is a choice we have to make. Over the next few weeks, I hope to share with you a few lessons that I have learnt at the wheel in my two decades of my career (prison). Thank you for reading, and do let me know what you think. Reference: Srini Chandra (3 Lives, in search of bliss), Pinal Dave (http://blog.sqlauthority.com) Filed under: PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority Book Review, T SQL, Technology

    Read the article

  • XAMPP pointing a file outside root folder

    - by Ravi
    I am using XAMPP for first time in Mac. Running out problems accessing other than root folder(htdocs).when I am placing my web application inside htdocs with default httpd.conf file it works when I try to point my web application url in httpd.conf it throws error I am aware that to modify the root folder I need to do changes to my XAMPP/etc/httpd.conf file With Default XAMPP MAC Settings, I am trying to change Server root,Document root and Directory in XAMPP/etc/httpd.conf file the following ServerRoot "/Users/ravi/Documents/Development/Backbone/backboneboilerplate" DocumentRoot "/Users/ravi/Documents/Development/Backbone/backboneboilerplate" <Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all </Directory> <Directory "/Users/ravi/Documents/Development/Backbone/backboneboilerplate"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> its throwing error when trying to start XAMPP httpd: Syntax error on line 54 of /Applications/XAMPP/xamppfiles/etc/httpd.conf: Cannot load /Users/ravi/Documents/Development/Backbone/backboneboilerplate/modules/mod_authn_file.so into server: cannot create object file image or add library

    Read the article

  • md5sum returns a different hash value than online hash generators

    - by Ravi
    On suse10, md5sum myname gives md5 hash as 49b0939cb2db9d21b038b7f7d453cd5d The file myname contains string "ravi" while some of the online md5 hash generators for the same string seem to give a different hash http://md5-encryption.com/ http://www.miraclesalad.com/webtools/md5.php They spit out the hash for "ravi" as 63dd3e154ca6d948fc380fa576343ba6 Why is there a difference in md5sum for the same string "ravi" ?

    Read the article

  • Unable to access other Volume in Vaio E series

    - by Rahul Ravi Kumar Shah
    Error mounting /dev/sda6 at /media/ravi/New Volume: mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sda6" "/media/ravi/New Volume" Exited with: non-zero exit status 14: The disk contains an unclean file system (0, 0). Metadata kept in Windows cache, refused to mount. Failed to mount '/dev/sda6': Operation not permitted The NTFS partition is in an unsafe state. Please resume and shutdown Windows fully (no hibernation or fast restarting), or mount the volume read-only with the 'ro' mount option.

    Read the article

  • Jdk 6.0 update 6 installed sucessfully but java command not working

    - by Ravi.Kumar
    I switched to linux (Ubuntu 12.04) this morning and find it great but messed up while installing java. :-(. I have installed jdk6.0_6 successfully but when I run java command in terminal, I get this ravi@ravi-LIFEBOOK-AH531:~$ java The program 'java' can be found in the following packages: * default-jre * gcj-4.6-jre-headless * openjdk-6-jre-headless * gcj-4.5-jre-headless * openjdk-7-jre-headless Try: sudo apt-get install <selected package> Could someone help me with this? Below are the steps that I followed to install: copied file named jdk-6u6-linux-x64.bin to my documents from terminal executed chmod a+x jdk-6u6-linux-x64.bin and then executed sudo ./jdk-6u6-linux-x64.bin In terminal I accepted the license agreement and done.

    Read the article

  • Stored procedure strange error when called through php

    - by ravi
    I have been coding a registration page(login system) in php and mysql for a website. I'm using two stored procedures for the same. First stored procedure checks wether the email address already exists in database.Second one inserts the user supplied data into mysql database. User has EXECUTE permission on both the procedures.When is execute them individually from php script they work fine. But when i use them together in script second Stored procedure(insert) not working. Stored procedure 1. DELIMITER $$ CREATE PROCEDURE reg_check_email(email VARCHAR(80)) BEGIN SET @email = email; SET @sql = 'SELECT email FROM user_account WHERE user_account.email=?'; PREPARE stmt FROM @sql; EXECUTE stmt USING @email; END$$ DELIMITER; Stored procedure 2 DELIMITER $$ CREATE PROCEDURE reg_insert_into_db(fname VARCHAR(40), lname VARCHAR(40), email VARCHAR(80), pass VARBINARY(32), licenseno VARCHAR(80), mobileno VARCHAR(10)) BEGIN SET @fname = fname, @lname = lname, @email = email, @pass = pass, @licenseno = licenseno, @mobileno = mobileno; SET @sql = 'INSERT INTO user_account(email,pass,last_name,license_no,phone_no) VALUES(?,?,?,?,?)'; PREPARE stmt FROM @sql; EXECUTE stmt USING @email,@pass,@lname,@licenseno,@mobileno; END$$ DELIMITER; When i test these from php sample script insert is not working , but first stored procedure(reg_check_email()) is working. If i comment off first one(reg_check_email), second stored procedure(reg_insert_into_db) is working fine. <?php require("/wamp/mysql.inc.php"); $r = mysqli_query($dbc,"CALL reg_check_email('[email protected]')"); $rows = mysqli_num_rows($r); if($rows == 0) { $r = mysqli_query($dbc,"CALL reg_insert_into_db('a','b','[email protected]','c','d','e')"); } ?> i'm unable to figure out the mistake. Thanks in advance, ravi.

    Read the article

  • Comma seprated search in mysql query

    - by Ravi Kotwani
    I have search mechanism in my site. For that I have written a large conditional query. $sql = "select * from users where keyword like '%".$_POST['search']."%' OR name like '%".$_POST['search']."%'"; Now, I suppose I have following data on the site: ID Name Keyword 1 Sanjay sanjay, surani 2 Ankit ankit, shah 3 Ravi ravi, kotwani Now, I need the result such that when user writes "sanjay, shah" ($_POST['search'] = 'sanjay, shah') then records 1 and 2 should be displayed. Can I achive this in single mysql query?

    Read the article

  • regular expression to remove original message from reply mail using in java ?

    - by ravi ravi
    In my forum, users can reply through email. I am handling mails from their reply. When they are replying the original message getting appended. I want to get only the reply message not the original message. I have to write regular expression for gmail & hotmail. I written regex for gmail as follows : \n.wrote:(?s).--End of Post-- It is removing the original message except date. I want to remove the date also. before removing the original message : " hi 33 On Tue, May 11, 2010 at 4:18 PM, Mmmmm, Rrrrr wrote: The following update has been posted to this discussion: test as user 222 [$MESSAGE_SIGNATURE_HEADER$] --End of Post-- " When I use the above regex it is filtering as follows : " hi 33 On Tue, May 11, 2010 at 4:18 PM, Mmmmm, Rrrrr " Here i want only the actual message 'hi 33' not that date. How can I filter the date using above regex? Also I need regex for Hotmail also. I appreciate for any reply. Thanks in advance.

    Read the article

  • C# Projects for study

    - by Chandra
    I need to learn C# for my Internship. I would not like to start programming top down reading a Ebook. I would like to set a Goal for myself and then try to achieve it Programmatically. So, I am here to ask your help, if you could suggest me some interesting projects which will help me in Learning C# efficiently and quickly. I have previous programming experience, programming in C,C++ and Matlab. Thanks for your time Chandra

    Read the article

  • iTunes resizing photos on sync.

    - by Ravi
    Hi All, When I synch my photos into iPhone/iPod through iTunes the photos are being resized to smaller ones. I need to get high resolution images without being resized into the device. Is there any way to do this other than saving images from mail or from browser etc ?. Thanks, Ravi

    Read the article

  • upgrade from windows server 2008 r2 std to enterprise

    - by Ravi
    We recently had to upgrade our servers from Win 2008 R2 Standard to Enterprise. The upgrade method was DISM. After the upgrade, a lot of weird things started to happen. Though Windows says it's been properly activated, we lost 1) RDP settings (disappeared from the Remote Setting tab of Properties of My Computer) 2) The option to join a domain is grayed out 3) The server had to 2 physical processors 12 cores each. Now, task manager or windows sees only 1 processor (or only 12 cores) 4) the amount of physical ram on this sever is 32 GB (Windows reports only 4 GB are usable) Has anyone encountered this before ? Thanks Ravi

    Read the article

  • csutom converter in XStream

    - by Raja Chandra Rangineni
    Hi All, I am using XStream to serialize my Objects to XML format. The formatted xml that I get is as below: node1, node2, node 3 are attributes of pojo,DetailDollars 100 25 10 I have requirement where in I have to calucluate a percentage, for example 100/ 25 and add the new node to the existing ones. So, the final output should be : 100 25 10 4 I wrote a custom converter and registered to my xstream object. public void marshal(..){ writer.startNode("node4"); writer.setValue(getNode1()/ getnode2() ); writer.endNode(); } But, the xml stream I get has only the new node: 4 I am not sure which xstream api would get me the desired format. could you please help me with this . Thanks, Raja chandra Rangineni.

    Read the article

  • custom converter in XStream

    - by Raja Chandra Rangineni
    Hi All, I am using XStream to serialize my Objects to XML format. The formatted xml that I get is as below: node1, node2, node 3 are attributes of pojo,DetailDollars DetailDollars node1 100 /node1 node2 25 /node2 node3 10 /node3 /DetailDollars I have requirement where in I have to calucluate a percentage, for example 100/ 25 and add the new node to the existing ones. So, the final output should be : DetailDollars node1 100 /node1 node2 25 /node2 node3 10 /node3 node4 4 /node4 DetailDollars I wrote a custom converter and registered to my xstream object. public void marshal(..){ writer.startNode("node4"); writer.setValue(getNode1()/ getnode2() ); writer.endNode(); } But, the xml stream I get has only the new node: DetailDollars node4 4 /node4 /DetailDollars I am not sure which xstream api would get me the desired format. could you please help me with this . Thanks, Raja chandra Rangineni.

    Read the article

  • MS Excel XML Header Footer

    - by Ravi
    Hello All, I'm generating a excel report in a XML Excel format. In this report I have to repeat the top 25 rows and bottom 10 rows on each page, like a header and a footer. Can you please guide me on the code that is required to accomplish this task. I'm using ColdFusion. Thank you. Ravi

    Read the article

  • Issues Migrating Ejb 2.0 from jboss 4 to jboss 5.1

    - by Ravi
    Deploying an EAR application in jboss 5.1 throws an error. Below is the error The content of element type "message-driven" must match "(description?,display-name?,small- icon?,large-icon?,ejb-name,ejb-class,transaction-type,message-selector?,acknowledge- mode?,message-driven-destination?,env-entry*,ejb-ref*,ejb-local-ref*,security-identity?,resource- ref*,resource-env-ref*)". This EAR application worked in JBoss 4.0.2, but not working on Jboss 5.1 Thanks Ravi S

    Read the article

  • triggering onchange event

    - by Ravi
    Hello All, I'm not able to get the below code to work. $("#grid_table td:nth-child(10) input").live("onchange",function () { alert("changed"); }); am I missing something here? Thanks. Ravi

    Read the article

  • Communicating to SAP XI through .NET - IDOC XML

    - by RAVI KOTA
    Hi Friends, I have a situation where in we need to send IDOC things to SAP XI from .NET application. It is like both sending and receiving. I guess that it is having something connected to translate IDoc to XML and vice versa and then communicate. Can you just some technical knowledge on how to achieve this communication between SAP XI and .NET for IDOCs Many thanks, Ravi Kota

    Read the article

  • ComboBox in Flex

    - by Ravi K Chowdary
    Hi, I have a combobox with multi selection. when i click on add button, which ever data is selected in the Combobox, those data has to be displayed in the another comboBox. Please check the code and Can anyone of you please help me on this. "/ Thanks, Ravi

    Read the article

  • Conversion from jpg to gif with reduced size

    - by Ravi
    Hello, This is nice code. But it is uncertain. I am trying with jpg to gif conversion. With some images it reduces the size and with some images it increase the size. Can you help me that how can i get the reduced sized gif from jpg. Thanks, ravi

    Read the article

1 2 3 4 5 6 7 8 9 10 11  | Next Page >