H1b-visa can i work for 2 companies, if I have 2 h1b-visa

I have h1 bwhich company x did for me. I still have that.

After a year company y did another h1 for me. I currently have 2 h1 though I work for company y on l1 which will expire next month.

I want to keep both h1b-visa and for both the companies. Is this legal.

You cannot work for them simultaneously. If you want to work for X/Y, and X/Y has not withdrawn the petition, you can work for them. If they have already withdrawn your petition, then they will have to file another petition for you to work for them (this will be cap-exempt).

Also, you are currently working on L-1. So in order to work on H-1 COS needs to be filed. It can be filed along w/ new petition or separately (if an old petiion is being used).

I had heard about concurrent h1 visas where a person can work into 2 companies.

The only thing is to make the number of hours appropriate and feasible.

Yes, there is concurrent H-1 but like you said only if you can satisfy both the LCA requirements. In case of concurrent H-1, one of the H-1s is typically part-time while the other one is full-time.